Create a separate NgModule that imports all of the Angular Material components

Posted at: April 5, 2019 2:22 PM

In this lesson we will learn, how to create a separate NgModule that imports all of the Angular Material components. You can import this module wherever you would like to use the Angular Material components.

Must be sure this NgModule import after BrowserModule.

Create a NgModule

Now a created MaterialDesignModule. You can import all of the Angular Material components in this module.

src/app/material-design/material-design.module.ts

Import NgModule MaterialDesignModule

Import this NgModule MaterialDesignModule wherever you would like to use the Angular Material components. For example import in AppModule

src/app/app-module.ts

Use in HTML

src/app/app.component.html

Conclusion

I have learnt in this lesson to creating a separate NgModule MaterialDesignModule and imports MatCheckboxModule, MatButtonModule of the Angular Material components for creating checkbox and button.

This lesson also available on YouTube
angular material import all modules angular material 2 demo angular material tutorial angular material components example angular material io components create ngmodule angular material tutorial angular ngmodel

Please leave comments

1 Comments