1 import { Injectable } from '@angular/core'
2 import { Subject } from 'rxjs/Subject'
3 import 'rxjs/add/operator/first'
4 import 'rxjs/add/operator/toPromise'
7 export class ConfirmService {
8 showConfirm = new Subject<{ title: string, message: string, inputLabel?: string, expectedInputValue?: string }>()
9 confirmResponse = new Subject<boolean>()
11 confirm (message: string, title = '') {
12 this.showConfirm.next({ title, message })
14 return this.confirmResponse.asObservable().first().toPromise()
17 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '') {
18 this.showConfirm.next({ title, message, inputLabel, expectedInputValue })
20 return this.confirmResponse.asObservable().first().toPromise()