forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 9
/
bottom-sheet-demo.ts
89 lines (80 loc) · 2.54 KB
/
bottom-sheet-demo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* @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 {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {
MatBottomSheet,
MatBottomSheetConfig,
MatBottomSheetModule,
MatBottomSheetRef,
} from '@angular/material/bottom-sheet';
import {MatButtonModule} from '@angular/material/button';
import {MatLegacyCardModule} from '@angular/material/legacy-card';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatLegacyFormFieldModule} from '@angular/material/legacy-form-field';
import {MatIconModule} from '@angular/material/icon';
import {MatLegacyInputModule} from '@angular/material/legacy-input';
import {MatLegacyListModule} from '@angular/material/legacy-list';
import {MatLegacySelectModule} from '@angular/material/legacy-select';
const defaultConfig = new MatBottomSheetConfig();
@Component({
selector: 'bottom-sheet-demo',
styleUrls: ['bottom-sheet-demo.css'],
templateUrl: 'bottom-sheet-demo.html',
standalone: true,
imports: [
CommonModule,
FormsModule,
MatBottomSheetModule,
MatButtonModule,
MatLegacyCardModule,
MatLegacyCheckboxModule,
MatLegacyFormFieldModule,
MatIconModule,
MatLegacyInputModule,
MatLegacySelectModule,
MatLegacyListModule,
],
})
export class BottomSheetDemo {
config: MatBottomSheetConfig = {
hasBackdrop: defaultConfig.hasBackdrop,
disableClose: defaultConfig.disableClose,
backdropClass: defaultConfig.backdropClass,
direction: 'ltr',
ariaLabel: 'Example bottom sheet',
};
@ViewChild(TemplateRef) template: TemplateRef<any>;
constructor(private _bottomSheet: MatBottomSheet) {}
openComponent() {
this._bottomSheet.open(ExampleBottomSheet, this.config);
}
openTemplate() {
this._bottomSheet.open(this.template, this.config);
}
}
@Component({
template: `
<mat-nav-list>
<a href="#" mat-list-item (click)="handleClick($event)" *ngFor="let action of [1, 2, 3]">
<span mat-line>Action {{ action }}</span>
<span mat-line>Description</span>
</a>
</mat-nav-list>
`,
standalone: true,
imports: [CommonModule, MatLegacyListModule],
})
export class ExampleBottomSheet {
constructor(private _bottomSheet: MatBottomSheetRef) {}
handleClick(event: MouseEvent) {
event.preventDefault();
this._bottomSheet.dismiss();
}
}