I used to import the Material library into the base module, app.module.ts, but Angular Material v2.0.0-beta.3 deprecates the Material module. According to the changelog (https://github.com/angular/material2/blob/master/CHANGELOG.md) you should now create a custom module that imports the individual Material components. I cannot make this work.
This approach:
@NgModule({
declarations: [ MdInputModule ],
imports: [
CommonModule,
MdInputModule
],
exports: [ MdInputModule ]
})
export class FooMaterialModule {}
Causes this error:
Uncaught Error: Unexpected module 'MdInputModule' declared by the module 'FooMaterialModule'. Please add a @Pipe/@Directive/@Component annotation.
How do I make a custom module for the Angular Material library?
You can create a feature module that looks like this:
Then import it in your app.module.ts:
Your custom Angular Material module can mirror the deprecated Material Module.
As the change log indicates, you would want to comment out Material components not used by your application.
my-material.module.ts
app.module.ts