Skip to content

Commit

Permalink
snackbar testing
Browse files Browse the repository at this point in the history
  • Loading branch information
zarend committed Oct 13, 2023
1 parent f5895a3 commit d06ffff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/dev-app/dialog/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ng_module(
"//src/material/form-field",
"//src/material/input",
"//src/material/select",
"//src/material/snack-bar",
],
)

Expand Down
2 changes: 2 additions & 0 deletions src/dev-app/dialog/dialog-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@ <h2>Other options</h2>
class="demo-dialog-button">
Change dimensions
</button>

<button (click)="openSnackbar()">Open snackbar</button>
</ng-template>
12 changes: 11 additions & 1 deletion src/dev-app/dialog/dialog-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {MatFormFieldModule} from '@angular/material/form-field';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {DragDropModule} from '@angular/cdk/drag-drop';
import {MatSnackBar, MatSnackBarModule} from '@angular/material/snack-bar';

const defaultDialogConfig = new MatDialogConfig();

Expand All @@ -43,6 +44,7 @@ const defaultDialogConfig = new MatDialogConfig();
MatFormFieldModule,
MatInputModule,
MatSelectModule,
MatSnackBarModule,
],
})
export class DialogDemo {
Expand Down Expand Up @@ -76,7 +78,11 @@ export class DialogDemo {

@ViewChild(TemplateRef) template: TemplateRef<any>;

constructor(public dialog: MatDialog, @Inject(DOCUMENT) doc: any) {
constructor(
public dialog: MatDialog,
public snackbar: MatSnackBar,
@Inject(DOCUMENT) doc: any,
) {
// Possible useful example for the open and closeAll events.
// Adding a class to the body if a dialog opens and
// removing it after all open dialogs are closed
Expand Down Expand Up @@ -112,6 +118,10 @@ export class DialogDemo {
this.dialog.open(this.template, this._getDialogConfig());
}

openSnackbar() {
this.snackbar.open('Hello from Dialog');
}

private _getDialogConfig(): MatDialogConfig {
const config = {...this.config};
if (this.enableLegacyPadding) {
Expand Down

0 comments on commit d06ffff

Please sign in to comment.