/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {Component, TemplateRef, ViewChild} from '@angular/core'; import { MatBottomSheet, MatBottomSheetConfig, MatBottomSheetRef, } from '@angular/material/bottom-sheet'; const defaultConfig = new MatBottomSheetConfig(); @Component({ moduleId: module.id, selector: 'bottom-sheet-demo', styleUrls: ['bottom-sheet-demo.css'], templateUrl: 'bottom-sheet-demo.html', }) export class BottomSheetDemo { config: MatBottomSheetConfig = { hasBackdrop: defaultConfig.hasBackdrop, disableClose: defaultConfig.disableClose, backdropClass: defaultConfig.backdropClass, direction: 'ltr' }; @ViewChild(TemplateRef, {static: false}) template: TemplateRef; constructor(private _bottomSheet: MatBottomSheet) {} openComponent() { this._bottomSheet.open(ExampleBottomSheet, this.config); } openTemplate() { this._bottomSheet.open(this.template, this.config); } } @Component({ template: ` Action {{ action }} Description ` }) export class ExampleBottomSheet { constructor(private _bottomSheet: MatBottomSheetRef) {} handleClick(event: MouseEvent) { event.preventDefault(); this._bottomSheet.dismiss(); } }