本文介绍了Angular - 模块 AppModule 导入的意外值 MatDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将 Angular Material 集成到 Angular 中,但出现以下错误.程序编译成功,但在浏览器中出现此问题.
I am trying to integrate Angular Material in Angular but getting following error. The program is compiled successfully but getting this issue in browser.
Uncaught Error: Unexpected value 'MatDialog' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (compiler.js:485)
at eval (compiler.js:15226)
at Array.forEach (<anonymous>)
at CompileMetadataResolver.getNgModuleMetadata (compiler.js:15201)
at JitCompiler._loadModules (compiler.js:34385)
at JitCompiler._compileModuleAndComponents (compiler.js:34346)
at JitCompiler.compileModuleAsync (compiler.js:34240)
at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:239)
at PlatformRef.bootstrapModule (core.js:5551)
at eval (main.ts:11)
推荐答案
你应该导入 MatDialogModule
代替.
@NgModule({
imports: [
...,
MatDialogModule
]
...
})
export class AppModule {}
另外不要忘记,选择器中的角度材料已经从 md
移动到 mat
.
Also don't forget that angular material has moved from md
to mat
in selectors.
这篇关于Angular - 模块 AppModule 导入的意外值 MatDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!