javascript - Angular - Ovärderat värde MatDialog importerat av modulen AppModule


Jag försöker integrera Angular Material i Angular men får följande fel. Programmet kompileras framgångsrikt men får detta problem i webbläsaren.

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)

Svar #1

Du bör istället importera MatDialogModule.

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

Glöm inte heller att Angular Material har flyttat från md till mat i selektorer.

Relaterade artiklar