forked from ui-router/sample-app-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialog.component.ts
54 lines (46 loc) · 1.25 KB
/
dialog.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Component, OnInit, HostBinding } from '@angular/core';
import { wait } from '../util/util';
@Component({
selector: 'app-dialog',
template: `
<div class="backdrop" [class.active]="visible"></div>
<div class='wrapper'>
<div class="content">
<h4 *ngIf="message">{{message}}</h4>
<div [hidden]="!details">{{details}}</div>
<div style="padding-top: 1em;">
<button class="btn btn-primary" (click)="yes()">{{yesMsg}}</button>
<button class="btn btn-primary" (click)="no()">{{noMsg}}</button>
</div>
</div>
</div>
`,
styles: [],
standalone: false
})
export class DialogComponent implements OnInit {
@HostBinding('class.dialog') dialog = true;
@HostBinding('class.active') visible: boolean;
message: string;
details: string;
yesMsg: string;
noMsg: string;
promise: Promise<any>;
constructor() {
this.promise = new Promise((resolve, reject) => {
this.yes = () => {
this.visible = false;
wait(300).then(resolve);
};
this.no = () => {
this.visible = false;
wait(300).then(reject);
};
});
}
yes() {}
no() {}
ngOnInit() {
wait(50).then(() => this.visible = true);
}
}