Angular 特征模块内的角度对话框抛出错误';mat对话框内容';不是已知元素
我总结了一个非常基本的场景: 包含包含对话框的模块的angular应用程序。如果我编译这个应用程序,它会成功编译,但会抛出上面的错误。但是,应用程序可以正确运行并正确打开对话框。 我的应用程序模块:Angular 特征模块内的角度对话框抛出错误';mat对话框内容';不是已知元素,angular,angular-material,Angular,Angular Material,我总结了一个非常基本的场景: 包含包含对话框的模块的angular应用程序。如果我编译这个应用程序,它会成功编译,但会抛出上面的错误。但是,应用程序可以正确运行并正确打开对话框。 我的应用程序模块: @NgModule({ declarations: [ AppComponent, DialogBodyComponent ], imports: [ BrowserModule, BrowserAnimationsModule, MatD
@NgModule({
declarations: [
AppComponent,
DialogBodyComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
MatDialogModule,
MyDlgModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
我的功能模块:
@NgModule({
declarations: [DlgManagerComponent],
imports: [
CommonModule,
MatDialogModule,
],
exports: [
DlgManagerComponent]
})
export class MyDlgModule { }
我知道,在9之前的版本中,这个错误是由于没有将对话框添加到entryComponents中造成的,但是这是根据帮助而来的,不再需要了(即使我这样做了,错误仍然会出现)
编译器的输出如下所示:
unchanged chunks
chunk {main} main.js, main.js.map (main) 25.3 kB [initial] [rendered]
Time: 431ms
: Compiled successfully.
ERROR in src/app/my-dlg/dialogInModule/dialogInModule.component.html:3:1 - error NG8001: 'mat-dialog-content' is not a known element:
1. If 'mat-dialog-content' is an Angular component, then verify that it is part of this module.
2. If 'mat-dialog-content' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3 <mat-dialog-content>
~~~~~~~~~~~~~~~~~~~~
src/app/my-dlg/dialogInModule/dialogInModule.component.ts:6:16
6 templateUrl: './dialogInModule.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component DialogInModuleComponent.
未更改的块
chunk{main}main.js,main.js.map(main)25.3 kB[首字母][呈现]
时间:431ms
:编译成功。
src/app/my dlg/dialogInModule/dialogInModule.component.html中出错:3:1-错误NG8001:“mat dialog content”不是已知元素:
1.如果“mat对话框内容”是一个角度组件,则验证它是否是此模块的一部分。
2.如果“mat dialog content”是一个Web组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到此组件的“@NgModule.schemas”以抑制此消息。
3.
~~~~~~~~~~~~~~~~~~~~
src/app/my dlg/dialogInModule/dialogInModule.component.ts:6:16
6 templateUrl:'./dialogInModule.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
组件对话框inModuleComponent的模板中出错。
有人能帮忙吗?还是这是一只虫子?
我正在使用Angular的10.1.2版和Angular/material的10.2.1版谢谢你,Edric,我忘了还将DialogInModuleComponent添加到声明数组中了 错误日志中的组件名称(
对话框inModuleComponent
)与功能模块中声明的组件名称(DlgManagerComponent
)不同。