Reputation: 1722
I created a plunker to recreate the problem: http://plnkr.co/edit/sPPB0Cq0PUg1jmzzZtXh
It contains a mini angular js app with angular-ui-bootsrap.
The problem:
I'm trying to use $modal service to open a modal window.
It opens, then after I close it, i cannot open it again.
Actually, when trying to open again, it appears to not open. but when navigating to another location in the angular app the modal suddenly appear(or modals if you clicked many times) .
I'm kinda lost and the documentation didn't really help me.
Can anyone check it out and tell me what am i doing wrong?
Upvotes: 4
Views: 2853
Reputation: 1722
After reviewing some cases in which the modal does work, i think i got a solution up at the same plunker i put before
http://plnkr.co/edit/sPPB0Cq0PUg1jmzzZtXh
You have to use $modalInstance to .close() and .dismiss() the modal.
the docs suggest one could use the injected $close $dismiss functions but using these caused the problem for me...
I left the problem as is and implemented the solution in new files so you can review both (at your pleasure).
--- EDIT ---
if all fails $scope.apply() (or $rootScope.apply())
i tried to scope.apply after issuing the signal to open the modal and it successfully showed the modal immidietaly instead of on the next cycle (which was triggered for example by going to another page)
Upvotes: 3