Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call function after modal loads angularjs ui bootstrap

I am using Angularjs UI bootstrap to render Modal windows in my project. But In some situation I want to call a function after the modal loads. I have tried with $timeout and $viewContentLoaded but no use. can any one help me to resolve this issue.

Thank you all.

like image 841
chandu Avatar asked Jun 23 '14 07:06

chandu


2 Answers

I go through the documentation of angular ui bootstrap and finally I found the solution.

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

opened - a promise that is resolved when a modal gets opened after downloading content's template and resolving all variables

to call function after model opens.

$modalInstance.opened.then(function(){
  alert('hi');
});
like image 76
chandu Avatar answered Nov 01 '22 15:11

chandu


Alternatively, you can use:

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

PS: this was originally pointed by @esqew user. I put it here just to be easier to find.

like image 28
Daniel Loureiro Avatar answered Nov 01 '22 17:11

Daniel Loureiro