Angular Material: Difference between revisions

From Wiki RB4
(Created page with "==Installation== * see")
 
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Installation==
==Installation==
* see
ng [[Angular#Add|add]] @angular/material
eg. will update index.html with
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
 
==Concepts==
Angular material is based on the The Component Dev Kit (CDK). It is a set of behavior primitives for building UI components. Sometimes it is important to understand the 'base' class to understand the material classes.
 
==Modules==
 
===Flex Layout===
adding to a project by:
<PROJECT_FOLDER> npm i -s @angular/flex-layout @angular/cdk
 
<TAG_NAME class="flex-container" fxLayout="[column|row|...] fxLayoutAlign="[see [https://tburleson-layouts-demos.firebaseapp.com/#/docs here]]">
  <SUBTAG_NAME fxFlex> // fxFlex tells the element to take the remainder of the screen in height
  </SUBTAG_NAME>
</TAG_NAME>
 
* layout could change in sub-tags
 
==Components==
 
===Forms===
* see https://edupala.com/how-to-implement-angular-material-form-in-angular/
* https://www.youtube.com/watch?v=uEjBcYenAlA
* https://stackblitz.com/edit/example-angular-material-reactive-form?file=app%2Fapp.component.css
 
x = myFormGroup.value; // all values as object
myFormGroup.valueChanges.subscribe(console.log); // monitor each single change
<ng-container *ngIf="..."> </ng-container>
 
===Context Menu===
* [https://stackblitz.com/edit/angular-material-context-menu?file=app%2Fcontext-menu-example.html example @ stackblitz]
 
===Sidenav and Drawer===
* sidenav is for the full app page, drawer for a dedicated area
 
===Tooltip===
* see header component of UweHeuer
* see [https://www.angularjswiki.com/material/tooltip/ Angular Wiki]
 
===Tree===
Material trees are based on the cdk tree.
====CDK Tree====
When the tree receives a DataSource it will call its connect() method which returns an observable that emits an array of data. Whenever the data source emits data to this stream, the tree will render an update.
 
==Open Topics==
* late installation of HammerJs [https://tudip.com/blog-post/how-to-install-angular-material/ see last chapter]
 
==Resources==
* [https://material.angular.io/components/categories Angular Material Home]
* [https://material.angular.io/guide/getting-started Standard Getting Started]
* [https://www.youtube.com/watch?v=jUfEn032IL8 Full Tutorial]
* [https://www.angularjswiki.com/de/angular/angular-material-icons-list-mat-icon-list/ <mat-icon> list]
* [https://material.io/resources/icons/?style=baseline Material Design Icons]

Latest revision as of 20:17, 25 October 2022

Installation[edit]

ng add @angular/material

eg. will update index.html with

 <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
 <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

Concepts[edit]

Angular material is based on the The Component Dev Kit (CDK). It is a set of behavior primitives for building UI components. Sometimes it is important to understand the 'base' class to understand the material classes.

Modules[edit]

Flex Layout[edit]

adding to a project by:

<PROJECT_FOLDER> npm i -s @angular/flex-layout @angular/cdk
<TAG_NAME class="flex-container" fxLayout="[column|row|...] fxLayoutAlign="[see here]">
  <SUBTAG_NAME fxFlex> // fxFlex tells the element to take the remainder of the screen in height
  </SUBTAG_NAME>
</TAG_NAME>
  • layout could change in sub-tags

Components[edit]

Forms[edit]

x = myFormGroup.value; // all values as object
myFormGroup.valueChanges.subscribe(console.log); // monitor each single change
<ng-container *ngIf="..."> </ng-container>

Context Menu[edit]

Sidenav and Drawer[edit]

  • sidenav is for the full app page, drawer for a dedicated area

Tooltip[edit]

Tree[edit]

Material trees are based on the cdk tree.

CDK Tree[edit]

When the tree receives a DataSource it will call its connect() method which returns an observable that emits an array of data. Whenever the data source emits data to this stream, the tree will render an update.

Open Topics[edit]

Resources[edit]