File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
src/material-examples/snack-bar-position Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ < mat-form-field >
2
+ < mat-select placeholder ="Horizontal position " [(value)] ="horizontalPosition ">
3
+ < mat-option value ="start "> Start</ mat-option >
4
+ < mat-option value ="center "> Center</ mat-option >
5
+ < mat-option value ="end "> End</ mat-option >
6
+ < mat-option value ="left "> Left</ mat-option >
7
+ < mat-option value ="right "> Right</ mat-option >
8
+ </ mat-select >
9
+ </ mat-form-field >
10
+ < mat-form-field >
11
+ < mat-select placeholder ="Vertical position " [(value)] ="verticalPosition ">
12
+ < mat-option value ="top "> Top</ mat-option >
13
+ < mat-option value ="bottom "> Bottom</ mat-option >
14
+ </ mat-select >
15
+ </ mat-form-field >
16
+
17
+ < button mat-button (click) ="openSnackBar() " aria-label ="Show an example snack-bar ">
18
+ Pool party!
19
+ </ button >
Original file line number Diff line number Diff line change
1
+ import { Component } from '@angular/core' ;
2
+ import {
3
+ MatSnackBar ,
4
+ MatSnackBarHorizontalPosition ,
5
+ MatSnackBarVerticalPosition ,
6
+ } from '@angular/material' ;
7
+
8
+ /**
9
+ * @title Snack-bar with configurable position
10
+ */
11
+ @Component ( {
12
+ selector : 'snack-bar-position-example' ,
13
+ templateUrl : 'snack-bar-position-example.html' ,
14
+ } )
15
+ export class SnackBarPositionExample {
16
+
17
+ horizontalPosition : MatSnackBarHorizontalPosition = 'start' ;
18
+ verticalPosition : MatSnackBarVerticalPosition = 'bottom' ;
19
+
20
+ constructor ( public snackBar : MatSnackBar ) { }
21
+
22
+ openSnackBar ( ) {
23
+ this . snackBar . open ( 'Canonball!!' , 'End now' , {
24
+ duration : 500 ,
25
+ horizontalPosition : this . horizontalPosition ,
26
+ verticalPosition : this . verticalPosition ,
27
+ } ) ;
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments