javascript - angular ui bootstrap: promise resolved/rejected when modal closed -


i'm working on angular , bootstap, using angular-ui-bootstrap bridge library. thing want achieve reuse modal component , wrap in promise resolved when modal closed (when pressing ok button) or rejected (cancel button pressed or clicked outside of modal).

as far can see, there $modal service comes bridge library, has 1 method available: open(options). there built-in angular promise implementation: $q. i'm looking way on how combine two.

i want have custom component (a service, factory?) provide startflow method return promise. calling startflow open bootstrap modal. when modal closed (positively or negatively), promisewould resolved or rejected.

can give hint on how implement that? ddin't manage find existing solution far...

the result property on object returned open promise behaves describe. in fact example in documentation @ https://angular-ui.github.io/bootstrap/#/modal uses it:

var modalinstance = $modal.open({   templateurl: 'mymodalcontent.html',   controller: 'modalinstancectrl',   size: size,   resolve: {     items: function () {       return $scope.items;     }   } });  modalinstance.result.then(function (selecteditem) {   $scope.selected = selecteditem; }, function () {   $log.info('modal dismissed at: ' + new date()); }); 

which can seen working in plunker http://plnkr.co/edit/ro5dnkg0p9wywlmcrqln?p=preview


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -