【问题标题】:Angular - Unexpected value MatDialog imported by the module AppModuleAngular - 模块 AppModule 导入的意外值 MatDialog
【发布时间】:2018-06-24 04:41:36
【问题描述】:

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

【问题讨论】:

  • @yurzui 试过了,现在它给出的属性 open 在 MatDialogModule 类型上不存在
  • @yurzui 试过了,现在它给出了新错误:compiler.js:485 Uncaught Error: Template parse errors: 'md-dialog-content' is not a known element
  • @yurzui 谢谢它的工作

标签: javascript angular typescript material-design angular-material


【解决方案1】:

您应该改为导入 MatDialogModule

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-10
    • 1970-01-01
    • 2017-04-16
    • 2019-09-12
    相关资源
    最近更新 更多