尝试在有角度的材料模态内加载组件时出错-angular 10



我正在尝试加载Angular材质模态中的组件并接收来自编译器的下一个错误:

ERROR in ... error NG8001: 'app-component-to-load' is not a known element:
1. If 'app-component-to-load' is an Angular component, then verify that it is part of this module.
2. If 'app-component-to-load' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

但两个组件都在同一模块中声明

这个例子很简单:

模态HTML(有角度的材料模态(

<div>
<app-component-to-load></app-component-to-load>
<div/> 

在模块的入口组件数组中添加app-component-to-load和对话框组件,它就会工作。

这是工作演示https://stackblitz.com/edit/angular-material-gplwpt

最新更新