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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48264880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 05:10:14  来源:igfitidea点击:

Angular - Unexpected value MatDialog imported by the module AppModule

javascriptangulartypescriptmaterial-designangular-material

提问by D555

I am trying to integrate Angular Material in Angular but getting following error. The program is compiled successfully but getting this issue in browser.

我正在尝试将 Angular Material 集成到 Angular 中,但出现以下错误。程序编译成功,但在浏览器中出现此问题。

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)

回答by yurzui

You should import MatDialogModuleinstead.

您应该MatDialogModule改为导入。

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

Also don't forget that angular material has moved from mdto matin selectors.

另外不要忘记,角材料已经从移动mdmat的选择。