-
Notifications
You must be signed in to change notification settings - Fork 6.7k
/
simple-snack-bar.ts
48 lines (42 loc) · 1.29 KB
/
simple-snack-bar.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
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Component, ViewEncapsulation, Inject, ChangeDetectionStrategy} from '@angular/core';
import {MdSnackBarRef} from './snack-bar-ref';
import {MD_SNACK_BAR_DATA} from './snack-bar-config';
/**
* A component used to open as the default snack bar, matching material spec.
* This should only be used internally by the snack bar service.
*/
@Component({
moduleId: module.id,
selector: 'simple-snack-bar',
templateUrl: 'simple-snack-bar.html',
styleUrls: ['simple-snack-bar.css'],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'class': 'mat-simple-snackbar',
}
})
export class SimpleSnackBar {
/** Data that was injected into the snack bar. */
data: { message: string, action: string };
constructor(
public snackBarRef: MdSnackBarRef<SimpleSnackBar>,
@Inject(MD_SNACK_BAR_DATA) data: any) {
this.data = data;
}
/** Dismisses the snack bar. */
dismiss(): void {
this.snackBarRef._action();
}
/** If the action button should be shown. */
get hasAction(): boolean {
return !!this.data.action;
}
}