-
Notifications
You must be signed in to change notification settings - Fork 280
/
app.component.ts
57 lines (47 loc) · 1.38 KB
/
app.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
55
56
57
import {Component, Optional} from '@angular/core';
import {MdDialog, MdDialogRef, MdSnackBar} from '@angular/material';
@Component({
selector: 'material2-app-app',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
})
export class Material2AppAppComponent {
isDarkTheme: boolean = false;
lastDialogResult: string;
foods: any[] = [
{name: 'Pizza', rating: 'Excellent'},
{name: 'Burritos', rating: 'Great'},
{name: 'French fries', rating: 'Pretty good'},
];
progress: number = 0;
constructor(private _dialog: MdDialog, private _snackbar: MdSnackBar) {
// Update the value for the progress-bar on an interval.
setInterval(() => {
this.progress = (this.progress + Math.floor(Math.random() * 4) + 1) % 100;
}, 200);
}
openDialog() {
let dialogRef = this._dialog.open(DialogContent);
dialogRef.afterClosed().subscribe(result => {
this.lastDialogResult = result;
})
}
showSnackbar() {
this._snackbar.open('YUM SNACKS', 'CHEW');
}
}
@Component({
template: `
<p>This is a dialog</p>
<p>
<label>
This is a text box inside of a dialog.
<input #dialogInput>
</label>
</p>
<p> <button md-button (click)="dialogRef.close(dialogInput.value)">CLOSE</button> </p>
`,
})
export class DialogContent {
constructor(@Optional() public dialogRef: MdDialogRef<DialogContent>) { }
}