Call function after modal loads angularjs ui boots

2019-02-08 22:38发布

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.

2条回答
唯我独甜
2楼-- · 2019-02-08 22:47

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');
});
查看更多
够拽才男人
3楼-- · 2019-02-08 22:50

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.

查看更多
登录 后发表回答