將所有模組包裝在一起
你還可以輕鬆地將所有要使用的角度模組包裝到一個模組中:
import { NgModule } from '@angular/core';
import { MdButtonModule, MdSnackBarModule, MdSidenavModule } from '@angular/material';
@NgModule({
imports: [
BrowserAnimationsModule,
MdButtonModule,
MdSnackBarModule,
MdSidenavModule
],
exports: [
MdButtonModule,
MdSnackBarModule,
MdSidenavModule
]
})
export class MaterialWrapperModule {}
之後,只需將模組匯入應用程式主模組:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { MaterialWrapperModule } from './material-wrapper.module.ts';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserAnimationsModule,
MaterialWrapperModule,
CommonModule,
// This is optional, use it when you would like routing in your app
// RouterModule.forRoot([
// { path: '', component: HomeView, pathMatch: 'full'}
// ])
],
declarations: [ AppComponent],
bootstrap: [ AppComponent ]
})
export class AppModule {}