Angular - Unexpected value MatDialog imported by the module AppModule

。_饼干妹妹 提交于 2019-12-23 10:06:30

问题


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)

回答1:


You should import MatDialogModule instead.

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

Also don't forget that angular material has moved from md to mat in selectors.



来源:https://stackoverflow.com/questions/48264880/angular-unexpected-value-matdialog-imported-by-the-module-appmodule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!