我正在尝试创建一个对话框,如材料设计页面Here中所示。我可以让按钮显示出来,点击它,对话框出现并且页面如预期变暗,但没有文字出现。我觉得我很接近,但我无法弄清楚我要去哪里错了。任何帮助表示赞赏,谢谢!Angular 2和Material Designs - 示例对话框为空
这里是我的代码:
import { Component, OnInit } from '@angular/core';
import {MdDialog} from '@angular/material';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
constructor(public dialog: MdDialog) { }
openDialog() {
this.dialog.open(DialogOverviewExampleDialog);
}
ngOnInit() {
}
}
@Component({
selector: 'dialog-overview-example-dialog',
templateUrl: './dialog-overview-example-dialog.html',
})
export class DialogOverviewExampleDialog {}
你得到一个错误的控制台?因为没有构造函数,所以你在'DialogOverviewComponent'中也缺少'dialogRef'依赖项。 –
是的。它说,找不到名称为'DialogOverviewExampleDialog'。)和找不到DialogOverviewExampleDialog的组件工厂。你把它添加到@ NgModule.entryComponents?即使它在那里。你能解释一下dialogRef的含义吗?稍后会在文档中提到它,但它不在示例代码中。 – gv0000
如果我尝试使用DialogOverviewExampleDialogComponent也给出了一个错误,“没有为DialogOverviewExampleDialog找到组件工厂,是否将它添加到@ NgModule.entryComponents?” – gv0000