Skip to content

Commit 0f27e5a

Browse files
tinayuangaojelbourn
authored andcommitted
demo(button): display snackbar when button is clicked (#6327)
1 parent 4353a4c commit 0f27e5a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/demo-app/a11y/button/button-a11y.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ <h2>Anchor elements</h2>
3939

4040
<section>
4141
<h2>Buttons in different colors</h2>
42-
<button md-button color="primary">Primary</button>
43-
<button md-button color="accent">Accent</button>
44-
<button md-button color="warn">Warn</button>
42+
<button md-button color="primary" (click)="openSnackBar('Color is primary.')">Primary</button>
43+
<button md-button color="accent" (click)="openSnackBar('Color is accent.')">Accent</button>
44+
<button md-button color="warn" (click)="openSnackBar('Color is warn.')">Warn</button>
4545
</section>
4646

4747
<section>

src/demo-app/a11y/button/button-a11y.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
2+
import {MdSnackBar} from '@angular/material';
33

44
@Component({
55
moduleId: module.id,
@@ -10,7 +10,16 @@ import {Component} from '@angular/core';
1010
export class ButtonAccessibilityDemo {
1111
counter: number = 0;
1212

13+
constructor(public snackBar: MdSnackBar) {}
14+
15+
openSnackBar(message: string) {
16+
this.snackBar.open(message, '', {
17+
duration: 2000,
18+
});
19+
}
20+
1321
increase() {
1422
this.counter++;
23+
this.openSnackBar(`Click counter is set to ${this.counter}`);
1524
}
1625
}

0 commit comments

Comments
 (0)