Introduction
In this article, we'll walk through the steps which are needed to set up an Angular project including the Angular Material Design Library in your project.
We're going to use the Angular CLI to start this project and I'm assuming you already have it installed. If you haven't, use the following command to install it globally.
Step 1: Create a project
Use the following command to create a new Angular project.
ng new MyNgAppWithMaterial
E.g.

Note
I am using my “D” Drive to save my project. You can select any path where you want to create the project.
It will create a new project. After the project is successfully created, go to the Angular Project folder by changing the directory
To check if everything is working correctly, we will run the project using the following command.
ng serve –o
E.g.

This command builds the application and opens it in our default browser.
To stop the server, press CTRL + C while you are on the command prompt and then "Y" and ENTER key. This will stop the server.
Step 2: Install Angular Material and Angular CDK
Type the following command to install the dependencies.
npm install --save @angular/material @angular/cdk
E.g.

Step 3: Install Animations
Some material components depend on the Angular animations module in order to be able to do more advanced transitions. If you want these animations to work in your app, you have to install the @angular/animations module and include the BrowserAnimationsModule in your app.
Command
npm install --save @angular/animations
E.g.

We need to import the Angular animation module into app.module.ts file.
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- // import the angular animation module
- import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
- import { AppComponent } from './app.component';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule, BrowserAnimationsModule
- ],
- providers: [],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
Step 4: Import the component modules
Next, for each material component we want to use in our project, we have to import it into the imports array of ngModule above.
If you only have a couple of components, you could import them directly into this file. However, for the purposes of organization and keeping your AppModule brief, you can create a custom module specifically for your material component imports. We'll do that.
To create a new module, use the following command.
Command
ng generate module material Or ng g m material
E.g.

-m=app.module option is used to register material to app.module or you can register it manually like below.
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- // import the angular animation module
- import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
- import { AppComponent } from './app.component';
- import { MaterialModule } from './material/material.module';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule, BrowserAnimationsModule, MaterialModule
- ],
- providers: [],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
Include all your required material component module, we're only including the MatInputModule like below in material.module
- import { NgModule } from '@angular/core';
- import { CommonModule } from '@angular/common';
- import {MatInputModule} from '@angular/material/input';
- @NgModule({
- imports: [
- CommonModule,
- MatInputModule
- ],
- exports: [MatInputModule],
- declarations: []
- })
- export class MaterialModule { }



Ravindra JijotiaPosted Apr 6, 2018, 4:08 AM
Angular 5 - http://ravindra-collections.blogspot.co.za/2018/04/getting-started-with-angular-material.html