Noo*_*ber 2 angular-material angular
我试图使用dialog角度材料.我正在尝试实现页面上给出的第一个示例:
Angular Material Dialog URL
这是上面给出的示例的Stackblitz URL:
Angular材料网站上提到的示例
我所做的唯一修改是将对话框组件移动到一个单独的文件夹中.但是对话框没有正确打开,也没有显示数据.这是我工作的Stackblitz链接: 我的实现
我认为数据不会在对话框组件中传递.但我无法弄清楚原因.任何帮助将受到高度赞赏.
在Stackblitz中,控制台在单击按钮后显示有用的错误消息:
ERROR
Error: No component factory found for DialogComponentComponent. Did you add it
to @NgModule.entryComponents?
Run Code Online (Sandbox Code Playgroud)
要解决此问题,您需要将对话框中显示的组件添加到app.module.ts中的entryComponents集合(或Stackblitz中的main.ts文件):
entryComponents: [DialogOverviewExample, DialogComponentComponent],
这是必需的,因为对话框中显示的组件未通过组件的选择器在模板中引用.由于Material的对话框组件按类型引用显示的组件,因此Angular需要知道在编译期间仍需要加载此组件并且不会发生树震动.如果您感兴趣,Angular文档会在entryComponents上进一步详细介绍.
| 归档时间: |
|
| 查看次数: |
2858 次 |
| 最近记录: |