Skip to content

Commit 6f04e65

Browse files
crisbetojelbourn
authored andcommitted
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.
1 parent 2f63195 commit 6f04e65

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<mat-form-field>
2+
<mat-label>Snack bar duration (seconds)</mat-label>
3+
<input type="number" [(ngModel)]="durationInSeconds" matInput>
4+
</mat-form-field>
5+
16
<button mat-button (click)="openSnackBar()" aria-label="Show an example snack-bar">
27
Pizza party
38
</button>

src/material-examples/snack-bar-component/snack-bar-component-example.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import {MatSnackBar} from '@angular/material';
1010
styleUrls: ['snack-bar-component-example.css'],
1111
})
1212
export class SnackBarComponentExample {
13+
durationInSeconds = 5;
14+
1315
constructor(private snackBar: MatSnackBar) {}
1416

1517
openSnackBar() {
1618
this.snackBar.openFromComponent(PizzaPartyComponent, {
17-
duration: 500,
19+
duration: this.durationInSeconds * 1000,
1820
});
1921
}
2022
}

0 commit comments

Comments
 (0)