📜  ng add @angular material - Shell-Bash (1)

📅  最后修改于: 2023-12-03 14:44:35.016000             🧑  作者: Mango

ng add @angular/material - Shell/Bash

Introduction

ng add @angular/material is a command used by developers to easily add Angular Material to their projects. This command will install the necessary packages and configure the project to use Angular Material with minimal setup required.

Usage

To use ng add @angular/material, open a command prompt or terminal and navigate to the root directory of your Angular project. Once there, simply type the following command:

ng add @angular/material

This will initiate the installation process and configure your project to use Angular Material.

What Does ng add @angular/material Do?

ng add @angular/material performs several steps to add Angular Material to your project:

  1. It installs the @angular/material and @angular/cdk packages along with their dependencies.
  2. It adds the necessary Material icons to your project by installing @angular/material-icons.
  3. It updates your styles.scss file to include the Material theme and typography.
  4. It adds the necessary dependencies to your app.module.ts file to enable Material components.

Once the installation is complete, you can start using Angular Material components in your project.

Additional Options

ng add @angular/material also provides some additional options that you can use:

  • --theme: This allows you to choose a pre-built Material theme for your project.
  • --hammerjs: This enables support for touch gestures in Material components by adding HammerJS to your project.

Example:

ng add @angular/material --theme=indigo-pink --hammerjs
Conclusion

By using ng add @angular/material, Angular developers can easily add Material Design to their projects without much effort. This command simplifies the installation process and eliminates the need for manual configuration.