Reputation: 660
I'm using ng-bind-html of AngularJS. I have to initialize a plugin after my Binding function is over. So I would like to know if there is a method or a function to do that work ?
Thanks for you answers !
Upvotes: 0
Views: 585
Reputation: 8971
One way you can do this is initialise a $watch
event over the variable you are using in your 'ng-bind'. Let m explain:
Suppose you have a span with an ng-bind like this:
<span ng-bind="val"></span>
Now, 'ng-bind' works in a way that whenever 'val' changes(within the digest cycle) it updates the value of the span, that is, it keeps a 'watch' on the 'val'. Similarly, we can use our own watch on the 'val' in the controller like this:
$scope.val; //your binded variable
$scope.$watch('val', function(newval, oldval) {
//here you can initialise your plugin and also access the old and new values of 'val'
})
Upvotes: 1