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

标签 javascript angular typescript material-design angular-material

我正在尝试将 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)

最佳答案

您应该改为导入 MatDialogModule

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

另外不要忘记, Angular Material 已从选择器中的 md 移动到 mat

关于javascript - Angular - 模块 AppModule 导入的意外值 MatDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48264880/

相关文章:

angular - 如果我发现自己一直在订阅另一个订阅中的内容,我应该怎么做?

typescript - npm 不更新 tsc 版本

javascript - 使用 javascript 的 Android 导航包装

asp.net - 将焦点设置在由 javascript 发起的回发上

javascript - 正则表达式在没有 www 的情况下不起作用

javascript - 在嵌套的 ng-repeat 中按 $index 跟踪的最佳方法是什么?

javascript - 属性在 promise 内未定义

angular - 无法更改 Angular 垫表列顺序

javascript - 如何从内容丰富的 CDA 响应中删除 sys 对象?

angular - 我认为变量不会反射(reflect)可观察值的值