【发布时间】:2019-09-13 10:31:19
【问题描述】:
我正在尝试在 div 容器内打开一个材质底部表,默认情况下它作为正文中的最后一个元素打开。
查看documentation,我需要使用viewContainerRef,但我无法使其工作。
这与我正在尝试做的类似:
app.component.html:
...
<div #container></div>
...
app.component.ts:
export class AppComponent implements AfterViewInit {
@ViewChild('container', { read: ViewContainerRef }) _container;
...
constructor(
private bottomSheet: MatBottomSheet,
) {}
ngAfterViewInit() {
this.bottomSheet.open(MySheetComponent, {
panelClass: 'my-modal',
viewContainerRef: this._container,
});
}
}
但它似乎没有任何改变。
任何帮助将不胜感激。
提前致谢
【问题讨论】:
-
我似乎遇到了同样的问题。看来 ViewContainerRef 没有做任何事情。我正在使用最新的 Angular 版本 (8.x.x)
标签: angular angular-material bottom-sheet