title: angular ui bootstrap: promise resolved/rejected when modal closed
body: <p>I'm working on angular and bootstap, using angular-ui-bootstrap bridge library. The thing I want to achieve is to reuse the <a href="https://angular-ui.github.io/bootstrap/#/modal" rel="noreferrer">modal component</a> and wrap it in a promise that would be resolved when the modal is closed successfully (when pressing <code>OK</code> button) or rejected (<code>cancel</code> button pressed or clicked outside of the modal).</p>
  
  <p>As far as I can see, there is the <code>$modal</code> service that comes from the bridge library, it has only one method available: <code>open(options)</code>. There is also built-in <a href="https://docs.angularjs.org/api/ng/service/$q" rel="noreferrer">angular promise implementation</a>: <code>$q</code>. I'm looking for a way on how to combine the two.</p>
  
  <p>I want to have a custom component (a service, factory?) which would provide a <code>startFlow</code> method that would return a promise. Calling <code>startFlow</code> would also open bootstrap modal. When the modal is closed (positively or negatively), the promisewould get resolved or rejected.</p>
  
  <p>Can somebody give a hint on how to implement that? I ddin't manage to find an existing solution so far...</p>