0

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 !

1 Answer 1

1

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'
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.