Angular-CLI + Angular Material Quick Development Tips - 2021

Rajratna maitry
3 min readMay 8, 2021

pre-require: Angular CLI basic understanding.

Start with installing angular CLI globally

npm install -g @angular/cli

Then create a new angular project and run the project with “— hmr” option

ng new my-first-project
cd my-first-project
ng serve --hmr

Hot Module Replacement (or HMR) is one of the most useful features offered by webpack. It allows all kinds of modules to be updated at runtime without the need for a full refresh.

Warning : HMR is not intended for use in production, meaning it should only be used in development.

Install Angular Material

Use the Angular CLI’s installation schematic to set up your Angular Material project by running the following command:

ng add @angular/material
Install angular material select them

Angular Material comes with multiple schematics that can be used to easily generate Material Design components e.g. navigation component

angular material auto-generated navigation component

Because the application running with ng serve — hmr, there no need to restart the application. this will automatically generate code and also compile code.

Creates a component with a responsive Material Design side nav and a toolbar for showing the app name. Now just include an app-navigation component in root a component.

Same as this add dashboard component.

dashboard material design

Include dashboard component in navigation component to load dashboard component.

dashboard material HTML code

<app-dashboard> is auto-generated component with material responsive design.

dashboard material preview

less than 5min responsive dashboard page with a navigation page is ready.

Other Generate Material Design components list :

address-form: Component with a form group that uses Material Design form controls to prompt for a shipping address.

table: Generates a component with a Material Design data table that supports sorting and pagination.

tree: Component that interactively visualizes a nested folder structure by using the <mat-tree> component.

For detailed information visit https://material.angular.io/guide/schematics

For more Stories https://rajratnamaitry.medium.com/

Claps help other people finding it and encourage me to write more posts

--

--