-
Notifications
You must be signed in to change notification settings - Fork 175
Use ng-click inside intro injected html #28
Comments
Same question, anyone? I imagine that the HTML has to be compiled before being injected, using $compile, but I can't make it work. @ahmedhawas did you manage do solve this? |
Same here. Does anyone know a workaround? I'd like to use a directive inside the template of a step. |
@rodrigovallades @ahmedhawas I got it figured out using $compile! First, define a callback on your ng-intro directive that's triggered when changing steps. ng-intro-options="introOptions" ng-intro-onafterchange="onIntroAfterChange" Second, configure the callback to compile the contents of the $scope.onIntroAfterChange = function () {
$timeout(function () {
var el = angular.element('.introjs-tooltip');
if (el.hasClass('compile')) {
$compile(el.contents())($scope);
}
}, 500);
}; Note: even though it's triggered after a change, I needed a timeout to ensure the new step was rendered on the DOM. Now you can add angular directives to the html of your steps, like an ng-click {
intro: '<button ng-click="onClick()">Click me</button>',
tooltipClass : 'some-class compile'
} Finally, the following method should be triggered! $scope.onClick = function () {
// great success!
} |
Great, @DURK ! Thanks for the reply! |
@DURK First of all - thanks for your solution. |
I haven't figured that out yet. I'll look into that when I get the chance. |
Is there a way to use ng-click inside the injected html injected in the popup. I tried using ng-click to call a function in the controller but it doesnt seem to work. I am not sure if I am missing something. Thanks
The text was updated successfully, but these errors were encountered: