Ich beginne gerade, Anuglar-Material2 in meinem Projekt zu verwenden, aber ich kann einfach keine Komponente richtig importieren. Nachdem ich einige Materialmodule in meinem app.module.ts importieren, bin ich Fehler wie immer folgende:Fehler bei der Verwendung von Angular-Material2
uncaught Error: Unexpected value 'MdButtonModule' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (compiler.es5.js:1690)
at compiler.es5.js:15383
at Array.forEach (<anonymous>)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15366)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._loadModules (compiler.es5.js:26796)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (compiler.es5.js:26769)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (compiler.es5.js:26698)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone (core.es5.js:4535)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule (core.es5.js:4521)
at Object.../../../../../src/main.ts (main.ts:11)
hier ist mein app.module.ts
import 'hammerjs';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppRoutingModule } from './app-routing.module';
import { SearchModule } from './search/search.module';
import { PostModule } from './post/post.module';
import { UserModule } from './user/user.module';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import {MdButtonModule, MdCheckboxModule} from '@angular/material';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { NavTopComponent } from './nav-top/nav-top.component';
import { AuthService } from './core/auth.service';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
NavTopComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
MdButtonModule,
MdCheckboxModule,
BsDropdownModule.forRoot(),
SearchModule,
PostModule,
UserModule,
AppRoutingModule
],
exports: [
],
providers: [AuthService],
bootstrap: [AppComponent]
})
export class AppModule { }
Ich habe genau Schritte alle, die enthalten in offiziellen Dokumentationen von Material2.
Welche Version von Angular verwenden Sie? Gehen Sie auch zu Ihrem 'node_modules/@ angular'-Ordner und prüfen Sie, ob sich der Ordner' material' dort befindet oder nicht? Wenn nicht, führen Sie 'npm install --save @ angular/material @ angular/cdk' erneut aus. – Nehal
Sie können auch die Dokumentation auschecken: https://stackoverflow.com/documentation/angular-material2/10828/getting-started-with-angular-material2#t=201707210758507458322 –
@MaciejTreder Ja, aber die Dokumente werden eine Weile dauern auszufüllen. :( – Edric