Maybe this can help you.
I've tried to implement @S.Klechkovski's solution here, it failed for me. But let anyone experiment with this.
But actually, I've made something you want here:
function appCtrl($scope, $compile) {
function onIntroAfterChange(targetElement, scope) {
angular.element(document.querySelector(".introjs-tooltiptext"))
.append($compile(
angular.element(
"<button my-directive>Test Directive</button>"))
(scope)).html()
}
$scope.onIntroAfterChange = onIntroAfterChange;
$scope.IntroOptions = {
steps: [{
element: "#step1",
intro: "Click the button:",
position: 'bottom'
}]
};
}
(the hint is to use ng-intro-onAfterChange
to compile there using proper scope)
The bad part is that I've hard-coded the template there.
But you can go further and set the template as an attribute of the element you want to show tooltip on. Had no possibility to access intro
field of a step. So... Sory for that extreme level of coding pornography here (it seems to be working):
Full JS:
angular.module("app", ["angular-intro"])
.directive("myDirective", myDirective)
.controller("appController", appCtrl);
function myDirective() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
console.log('you clicked the directive');
});
}
};
};
function appCtrl($scope, $compile) {
function onIntroAfterChange(targetElement, scope) {
angular.element(document.querySelector(".introjs-tooltiptext"))
.append($compile(
angular.element(targetElement).attr("data-template"))
(scope)).html()
}
$scope.onIntroAfterChange = onIntroAfterChange;
$scope.IntroOptions = {
steps: [{
element: "#step1",
intro: "Click the button:",
position: 'bottom'
}]
};
}
Full HTML
<body ng-app="app" ng-controller="appController">
<div ng-intro-options="IntroOptions" ng-intro-autostart="true" ng-intro-onafterchange="onIntroAfterChange">
<p id="step1" data-template="<button my-directive>Test Directive</button>">
Text
</p>
<button my-directive>Test Directive</button>
Note: here is the scary tip that you might need to wrap the code inside the onIntroAfterChange
with $timeout
. Hope you won't need it
PS: Actually the problem is that we are using IntroJS from AngularJS. Libs have completely different approaches, so mixing them is a pain.
PPS: Hope someone could provide better solution than I did.
PPS: The best solution is too rewrite introJS using Angular directives