docs(snack-bar): make custom component example more user-friendly (#15116)

Adds the ability to control the duration of the snack bar in the custom snack bar demo. Also bumps the default duration so people have more time to read it.

Fixes #15043.
This commit is contained in:
Kristiyan Kostadinov
2019-02-07 22:21:05 +01:00
committed by Jeremy Elbourn
parent 8ddcb5ba20
commit d69bc45ed1
2 changed files with 8 additions and 1 deletions
@@ -1,3 +1,8 @@
<mat-form-field>
<mat-label>Snack bar duration (seconds)</mat-label>
<input type="number" [(ngModel)]="durationInSeconds" matInput>
</mat-form-field>
<button mat-button (click)="openSnackBar()" aria-label="Show an example snack-bar">
Pizza party
</button>
@@ -10,11 +10,13 @@ import {MatSnackBar} from '@angular/material';
styleUrls: ['snack-bar-component-example.css'],
})
export class SnackBarComponentExample {
durationInSeconds = 5;
constructor(private snackBar: MatSnackBar) {}
openSnackBar() {
this.snackBar.openFromComponent(PizzaPartyComponent, {
duration: 500,
duration: this.durationInSeconds * 1000,
});
}
}