Skip to content

demo(button): display snackbar when button is clicked #6327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/demo-app/a11y/button/button-a11y.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ <h2>Anchor elements</h2>

<section>
<h2>Buttons in different colors</h2>
<button md-button color="primary">Primary</button>
<button md-button color="accent">Accent</button>
<button md-button color="warn">Warn</button>
<button md-button color="primary" (click)="openSnackBar('Color is primary.')">Primary</button>
<button md-button color="accent" (click)="openSnackBar('Color is accent.')">Accent</button>
<button md-button color="warn" (click)="openSnackBar('Color is warn.')">Warn</button>
</section>

<section>
Expand Down
11 changes: 10 additions & 1 deletion src/demo-app/a11y/button/button-a11y.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component} from '@angular/core';

import {MdSnackBar} from '@angular/material';

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

constructor(public snackBar: MdSnackBar) {}

openSnackBar(message: string) {
this.snackBar.open(message, '', {
duration: 2000,
});
}

increase() {
this.counter++;
this.openSnackBar(`Click counter is set to ${this.counter}`);
}
}