title: How to create Promise, for modal confirm dialog
body: <p>I am actually using Angular 2, but I found a solution, but it seems to me like it is just an workaround. And it isn't fully working right now.
  <br>
  I created an service, that can be injected anywhere, and an component, that sits at root component template.</p>
  
  <pre class="lang-js prettyprint-override"><code>class DialogService {
      output: Subject&lt;DialogEvent&gt;
  
      constructor(){
          this.output = new Subject()
      }
  
      ask(question = 'Are you sure?', accept = 'Ok', cancel = 'Cancel') {
          var input = new Subject()
          this.output.next({question, cancel, accept, input})
          return input.toPromise()
      }
  }
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>class DialogComponent {
      private output: Subject&lt;boolean&gt;
      texts: DialogEvent = {}
  
      constructor(private dialogService: DialogService) {
          this.dialogService.output.subscribe(event =&gt; {
              this.texts = event
              this.output = event.input
              this.show()
          })
      }
  
      cancel() {
          this.output.next(false)
          this.hide()
      }
  
      accept() {
          this.output.next(true)
          this.hide()
      }
  }
  </code></pre>
  
  <p>This setup works to the point, that it will open on ask in service, and close, with correct function (accept, or cancel), but the promise is not created, or fired.</p>
  
  <p>Anyway, if there is a better way to make this work, I al 100% for it.</p>