mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
Jeremy Elbourn
parent
8ddcb5ba20
commit
d69bc45ed1
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user