Angular - 模块AppModule导入的意外值MatDialog

问题描述 投票:4回答:1

我试图在Angular中集成Angular Material但是会出现以下错误。该程序已成功编译,但在浏览器中遇到此问题。

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)
javascript angular typescript material-design angular-material
1个回答
16
投票

你应该导入MatDialogModule

@NgModule({
  imports: [
    ...,
    MatDialogModule 
  ]
  ...
})
export class AppModule {}

另外,不要忘记角度材料已从md移动到选择器中的mat

© www.soinside.com 2019 - 2024. All rights reserved.