安装角度材料后,我在角度4项目中出现此错误
模块'AppModule'声明的意外模块'MdAutocompleteModule'。请添加@ Pipe / @ Directive / @ Component注释。
那是我的app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { environment } from './../environments/environment';
import { AngularFireModule } from 'angularfire2';
// New imports to update based on AngularFire2 version 4
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireAuthModule } from 'angularfire2/auth';
// import material
import { CdkTableModule } from '@angular/cdk';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {
FullscreenOverlayContainer,
MdAutocompleteModule,
MdButtonModule,
MdButtonToggleModule,
MdCardModule,
MdCheckboxModule,
MdChipsModule,
MdCoreModule,
MdTableModule,
MdDatepickerModule,
MdDialogModule,
MdExpansionModule,
MdGridListModule,
MdIconModule,
MdInputModule,
MdListModule,
MdMenuModule,
MdNativeDateModule,
MdPaginatorModule,
MdProgressBarModule,
MdProgressSpinnerModule,
MdRadioModule,
MdRippleModule,
MdSelectModule,
MdSidenavModule,
MdSliderModule,
MdSlideToggleModule,
MdSnackBarModule,
MdSortModule,
MdTabsModule,
MdToolbarModule,
MdTooltipModule,
OverlayContainer,
StyleModule
} from '@angular/material';
export const MaterialModules = [
MdAutocompleteModule,
MdButtonModule,
MdButtonToggleModule,
MdCardModule,
MdCheckboxModule,
MdChipsModule,
MdTableModule,
MdDatepickerModule,
MdDialogModule,
MdExpansionModule,
MdGridListModule,
MdIconModule,
MdInputModule,
MdListModule,
MdMenuModule,
MdCoreModule,
MdPaginatorModule,
MdProgressBarModule,
MdProgressSpinnerModule,
MdRadioModule,
MdRippleModule,
MdSelectModule,
MdSidenavModule,
MdSlideToggleModule,
MdSliderModule,
MdSnackBarModule,
MdSortModule,
MdTabsModule,
MdToolbarModule,
MdTooltipModule,
MdNativeDateModule,
StyleModule
];
@NgModule({
declarations: [
AppComponent,
MaterialModules
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFireDatabaseModule, // imports firebase/database, only needed for database features
AngularFireAuthModule, // imports firebase/auth only needed for auth features
BrowserAnimationsModule,
CdkTableModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
答案 0 :(得分:13)
您没有导入该模块
declarations: [
AppComponent,
////////////////////removed///////////////////////
],
imports: [
...MaterialModules, ////////////added here
BrowserModule,
FormsModule,
HttpModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFireDatabaseModule, // imports firebase/database, only needed for database features
AngularFireAuthModule, // imports firebase/auth only needed for auth features
BrowserAnimationsModule,
CdkTableModule
],