I'm working on angular and bootstap, using angular-ui-bootstrap bridge library. The thing I want to achieve is to reuse the modal component and wrap it in a promise that would be resolved when the modal is closed successfully (when pressing OK
button) or rejected (cancel
button pressed or clicked outside of the modal).
As far as I can see, there is the $modal
service that comes from the bridge library, it has only one method available: open(options)
. There is also built-in angular promise implementation: $q
. I'm looking for a way on how to combine the two.
I want to have a custom component (a service, factory?) which would provide a startFlow
method that would return a promise. Calling startFlow
would also open bootstrap modal. When the modal is closed (positively or negatively), the promisewould get resolved or rejected.
Can somebody give a hint on how to implement that? I ddin't manage to find an existing solution so far...
.promise
instead of.result
, which is unguessably thenable. – Calie