Call function after modular loads angularjs ui bootstrap

I am using Angularjs UI bootstrap to render modal windows in my project. But in some situations, I want to call a function after modal loads. I tried with $timeout and $viewContentLoaded but not used. can anyone help me solve this problem.

Thanks to everyone.

+6
source share
2 answers

I am looking through the angular ui bootstrap documentation and finally found a solution.

The open method returns a modal instance , an object with an opened property:

opened - a promise that is resolved when the modal opens after loading the content template and resolving all variables

to call the function after opening the model.

 $modalInstance.opened.then(function(){ alert('hi'); }); 
+11
source

Alternatively you can use:

 $modalInstance.rendered.then(function(){ alert('hi'); }); 

PS: this was originally pointed out by @esqew. I put it here to make it easier to find.

+4
source

Source: https://habr.com/ru/post/971203/


All Articles