11

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.

3
  • You mean MODALS?? Im not sure I follow you problem Commented Jun 23, 2014 at 7:27
  • can you post some code? for better guidance, I think I've had the same problem before and I solved it. some code can go a long way :3 Commented Jun 23, 2014 at 7:28
  • thanks @Gabriel Matusevich. I go through the documentation of angular ui bootstrap and I found the solution Commented Jun 23, 2014 at 7:30

2 Answers 2

15

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

6 Comments

awesome, that was the problem I had before .. :D i was trying to do something before the promise was resolved .... good to know that you found the solution
but here handle the opened method from $modelInstance in biggest issue. I am trying to call that method
the above method call the function on model loading
If you need to do DOM manipulation and you're waiting for the controller to be loaded and rendered, you might be looking for $modalInstance.rendered.then(....
Can you give me a code snippet for the above solution ? urgent
|
7

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.

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.