Show Menu
Cheatography

Angular Materials 8 Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

CDK

Common Behaviors
Accessibility
Bidirectionality
Drag and Drop
Layout
Observers
Overlay
Platform
Portal
Scrolling
Text field
Components
Stepper
Table
Tree

Components

Form Controls
Autocomplete
Checkbox
Datepicker
Form field
Input
Radio button
Select
Slider
Slide toggle
Navigation
Menu
Sidenav
Toolbar
Layout
Card
Divider
Expansion Panel
Grid list
List
Stepper
Tabs
Tree
Buttons & Indicators
Button
Button toggle
Badge
Chips
Icon
Progress spinner
Progress bar
Ripples
Popups & Modals
Bottom Sheet
Dialog
Snackbar
Tooltip
Data table
Paginator
Sort header
Table

Schematics

addres­s-form
Component with a form group that uses Material Design form controls to prompt for a shipping address
navigation
Creates a component with a responsive Material Design sidenav and a toolbar for showing the app name
dashboard
Component with multiple Material Design cards and menus which are aligned in a grid layout
table
Generates a component with a Material Design data table that supports sorting and pagination
tree
Component that intera­ctively visualizes a nested folder structure by using the <ma­t-t­ree> component
drag-drop*
Component that uses the
@angul­ar/­cdk­/dr­ag-drop
directives for creating an intera­ctive to-do list
ng g @angular/material:<schematics> <name>

*
ng g @angular/cdk:drag-drop <name>
 

Autoco­mplete

Simple
<mat-form-field>
 ­ ­<input type="text"
   matInput
   [formControl]="myControl"
   [matAutocomplete]="auto">
</mat-form-field>

<mat-autocomplete
 #auto="matAutocomplete">
  <mat-option
 ­ ­ ­*ng­For­="let option of options"
   [value]="option">
    {{option}}
  </mat-option>
</mat-autocomplete>

export class Autoco­mpl­ete­Sim­ple­Example {
 ­ ­myC­ontrol = new FormControl();
 ­ ­opt­ions: string[] = ['One', 'Two', 'Three'];
}
Filter
<mat-option
 ­*ng­For­="let option of options | async"
 [value]="option">

options: Observable<string[]>;

ngOnInit() {
 ­ ­thi­s.o­ptions =
    this.myControl.valueChanges
    .pipe(
      startWith(''),
 ­ ­ ­ ­ ­ ­map­(value => this._filter(value))
    );
}

private _filte­r(v­alue: string: string[] {
  ...
 ­ ­return filteredArray;
}
Group
<mat-autocomplete
 #auto="matAutocomplete">
  <mat-optgroup
 ­ ­ ngFor=­"let group of groups | async"
   [label]="group.name">
    <mat-option
 ­ ­ ­ ­ 
ngFor=­"let option of group.options"
     [value]="option">
      {{option.name}}
    </mat-option>
  </mat-optgroup>
</m­at-­aut­oco­mpl­ete>