Closed bobwiller closed 9 years ago
According to this plunk http://plnkr.co/edit/fOlMrJh0hN8oLDMVxk9s?p=preview
It looks like closing a modal resolves the error part of the promise.
instance.result.then(function (result) {
//Does nothing
},function(result){
//This gets called
});
To add to Tyler's answer: In UI Bootstrap, that promise is resolved when instance.close()
or $scope.$close()
is called and rejected when instance.dismiss()
or $scope.$dismiss()
is called. The intended use is you call close()
on the click event of an OK/Save button that is supposed to change something, and everything else that a user does to close the modal (press Esc, click outside the modal, click the ×, or click a Cancel button) is a dismiss
action instead. See their example in the link.
So if you don't call close()
anywhere because you're not changing anything in the lightbox, then the modal is always dismiss
ed and you only need the rejection handler for the promise. To handle both close
and dismiss
, you can do this:
instance.result['finally'](function (result) {
// ...
});
Sorry if this is a simple question, but how do I catch the promise when the lightbox is closed? I was hoping if I had:
var instance = Lightbox.openModal(images,index);
I could then do this:
instance.result.then(function (result) {...});
But it doesn't seem to catch the promise? Thanks, Bob