Skip to content

Commit 848ea8b

Browse files
committed
docs(snack-bar): make custom component example more user-friendly
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 a4c235a commit 848ea8b

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</mat-label>
3+
<input type="number" [(ngModel)]="duration" 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+
duration = 5000;
14+
1315
constructor(private snackBar: MatSnackBar) {}
1416

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

0 commit comments

Comments
 (0)