]>
Commit | Line | Data |
---|---|---|
1 | import { Injectable } from '@angular/core' | |
2 | import { Subject } from 'rxjs/Subject' | |
3 | import 'rxjs/add/operator/first' | |
4 | import 'rxjs/add/operator/toPromise' | |
5 | ||
6 | @Injectable() | |
7 | export class ConfirmService { | |
8 | showConfirm = new Subject<{ title: string, message: string, inputLabel?: string, expectedInputValue?: string }>() | |
9 | confirmResponse = new Subject<boolean>() | |
10 | ||
11 | confirm (message: string, title = '') { | |
12 | this.showConfirm.next({ title, message }) | |
13 | ||
14 | return this.confirmResponse.asObservable().first().toPromise() | |
15 | } | |
16 | ||
17 | confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '') { | |
18 | this.showConfirm.next({ title, message, inputLabel, expectedInputValue }) | |
19 | ||
20 | return this.confirmResponse.asObservable().first().toPromise() | |
21 | } | |
22 | } |