chandu
chandu

Reputation: 2276

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.

Upvotes: 11

Views: 16999

Answers (2)

Daniel Loureiro
Daniel Loureiro

Reputation: 5323

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.

Upvotes: 7

chandu
chandu

Reputation: 2276

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');
});

Upvotes: 15

Related Questions