How can I create my own materials module using Angular Material 2?

I checked the latest angular / material2 and in the release note they said MaterialModule is deprecated. here are the words from the release note.

MaterialModule

MaterialModule (and MaterialRootModule) are marked as deprecated. We found that with the current state of tremors in the world, using an aggregate NgModule like MaterialModule results in tools failing to eliminate code for components that are not being used.

To ensure users have the minimum amount of code possible, we are deprecating MaterialModule, which should be removed in a future release.

To replace MaterialModule, users can create their own "Material" module in their application (such as the GmailMaterialModule), which only imports the set of components actually used in the application._

So now MaterialModule is deprecated, I think I shouldn't write it in the imports

NgModules array (please correct me if I'm wrong). Then how can I use <md-card>

, md-button

and other components. The release note says that the user can create their own Material module, which is what it means.

can anyone show me a demo of how i can create my own material module?

+3


source to share


1 answer


I found an answer in the future to understand where they update the docs. https://github.com/angular/material2/compare/2.0.0-beta.3...master

Step 3: import component modules

Add MaterialModule as import to the root of the NgModule application.



Import NgModule for each component you want to use:

import {MdButtonModule, MdCheckboxModule} from '@angular/material';

@NgModule({
  imports: [MdButtonModule, MdCheckboxModule]
})

      

In short, you need to separately specify the components in the NgModel that you would like to use instead of a single main module. This is done to remove redundant / unused code from the package when generating an assembly.

+3


source







All Articles