Angular UI/Material Design Flashcards
Angular Flex-Layout
https://www.npmjs.com/package/@angular/flex-layout
Angular Flex Layout provides a sophisticated layout API using Flexbox CSS + mediaQuery. This module provides Angular developers with component layout features using a custom Layout API, mediaQuery observables, and injected DOM flexbox-2016 CSS stylings.
The Flex Layout engine intelligently automates the process of applying appropriate Flexbox CSS to browser view hierarchies. This automation also addresses many of the complexities and workarounds encountered with the traditional, manual, CSS-only application of box CSS.
The real power of Flex Layout, however, is its responsive engine. The Responsive API enables developers to easily specify different layouts, sizing, visibilities for different viewport sizes and display devices.
Getting Started
Start by installing the Angular Layout library from npm
npm i -s @angular/flex-layout @angular/cdk
Next, you’ll need to import the Layout module in your app’s module.
app.module.ts
import { FlexLayoutModule } from ‘@angular/flex-layout’;
…
@NgModule({ ... imports: [ FlexLayoutModule ], ... }); After that is configured, you can use the Angular Layout attributes in your HTML tags for flex layout:
<div>
</div>
https://github.com/angular/flex-layout
Angular Flex-Layout static API Overview
The Angular Layout features provide smart, syntactic directives to allow developers to easily and intuitively create responsive and adaptive layouts using Flexbox and CSS Grid.
The API outline here is considered static and provides a UX that will adjust element sizes and positions as the browser window width changes. The static API can be considered the default desktop layout API.
Developers should use the Responsive API to support alternate layout configurations for mobile or tablet devices
The Angular Layout API is an intuitive list of HTML directives (aka attributes) that can be used on HTML containers and elements. Instead of using traditional CSS stylesheets, developers will define their layouts declaratively directly in the HTML.
An important, fundamental concept is understanding which APIs are used on DOM containers versus APIs used on DOM child elements in those containers.
angular flex layout static api for DOM container
HTML API Allowed values
fxLayout [wrap] row | column | row-reverse | column-reverse
fxLayoutAlign main-axis: start | center | end | space-around | space-between | space-evenly; cross-axis: start | center | end | stretch | space-between | space-around | baseline
fxLayoutGap % | px | vw | vh
gdAlignColumns main-axis: start | center | end | space-around | space-between | space-evenly | stretch; cross-axis: start | center | end | stretch
gdAlignRows main-axis: start | center | end | space-around | space-between | space-evenly | stretch; cross-axis: start | center | end | stretch
gdAreas names separated by |, e.g. gdAreas=”area1 | area2 | area3” gdInline for inline-grid
gdAuto row | column | dense | row dense | column dense gdInline for inline-grid
gdColumns any valid input for grid-template-columns gdInline for inline-grid
! at the end means grid-auto-columns
gdRows any valid input grid-template-rows gdInline for inline-grid
! at the end means grid-auto-rows
gdGap % | px | vw | vh gdInline for inline-grid
These directives affect the flow and layout children elements in the container
angular flex layout static api for DOM elements
API for DOM elements: HTML Allowed values fxFlex "" | px | % | vw | vh | , fxFlexOrder int fxFlexOffset % | px | vw | vh fxFlexAlign start | baseline | center | end fxFlexFill, fxFill gdArea string name for the area as defined in gdAreas gdColumn any valid value for grid-column gdRow any valid value for grid-row gdGridAlign These directives affect the layout and size of the host element. Note the API expects their host elements to be inside a DOM container (a 'block' element which is itself using the Layout API for containers).
angular flex layout static api for any element
API for any element: HTML API Allowed values fxHide TRUE | FALSE | 0 | "" fxShow TRUE | FALSE | 0 | "" ngClass @extends ngClass core ngStyle @extends ngStyle core imgSrc @extends src attribute Shown below is sample HTML markup that uses both the container and element Static API:
<div>
<div></div>
<div>
<div></div>
<div></div>
<div></div>
</div>
<div></div>
</div>
Angular Layout directives assign CSS styles directly in-line to the host element. These in-line styles override inherited styles, ShadowDOM styles and even ShadowDOM tree stylings on the element :host
Prgrammatic usage for angular flex layout
Most of the Angular Layout functionality is provided via Directives used declaratively in template HTML. There are two (2) programmatic features, however, that are published for programmatic usages:
MediaObserver:
Injectable service used to subscribe to MediaQuery activation changes. You can access its observable through the media$ property
import {MediaObserver} from ‘@angular/flex-layout’;
constructor(public mediaObserver: MediaObserver ) {
mediaObserver.media$.subscribe(…);
}
BREAKPOINT:
Injection token used to override or extend the default breakpoints with custom MediaQuery breakpoints.
import {BREAKPOINT} from ‘@angular/flex-layout’;
providers: [{provide: BREAKPOINT, useValue: MY_CUSTOM_BREAKPOINTS, multi: true}]
Special Responsive Features
Special Responsive Features
While the following APIs also add or remove DOM element inline styles, they are NOT FlexBox CSS specific.
Instead these are Responsive APIs used to adjust specific, non-flexbox styles when a specific mediaQuery has activated:
fxShow: This markup specifies if its host element should be displayed (or not)
<div></div>
fxHide: This markup specifies if its host element should NOT be displayed
<div></div>
ngClass : Enhances the ngClass directives with class changes based on mediaQuery activations
<div></div>
ngStyle: Enhances the ngStyle directive with style updates based on mediaQuery activations
<div></div>
Static API:
HTML API (Declarative) The features of Angular Layout are best used declaratively in template HTML. This API has two (2) significant feature sets:
Static API: Summary of static API features.
Responsive API: Introducing Responsive API and BreakPoints details.
As each directive (aka API) within the library has its own constraints and options, the links below should be used to navigate to the specific documentation pages for each directive
Containers
This API set applies CSS stylings for DOM container elements with 1 or more nested children:
fxLayout: Defines the flow order of child items within a flexbox container
<div></div>
fxLayoutGap: Defines if child items within a flexbox container should have a gap
<div></div>
fxLayoutAlign: Defines how flexbox items are aligned according to both the main-axis and the cross-axis, within a flexbox container
<div></div>
gdAlignColumns: Aligns the items column-wise
<div></div>
gdAlignRows: Aligns the items row-wise
<div></div>
gdAreas: Describes the areas the grid contains
<div></div>
gdAuto: Controls the auto placement for the grid
<div></div>
gdColumns: Defines the line names and track sizing functions of the grid columns
<div></div>
gdRows: Defines the line names and track sizing functions of the grid rows
<div></div>
gdGap: Defines the gap between grid items
<div></div>
Child Elements within Containers
This API set applies CSS stylings for a DOM element nested within a DOM container:
fxFlex: This markup specifies the resizing of its host element within a flexbox container flow
<div></div>
fxFlexOrder: Defines the order of a flexbox item
<div></div>
fxFlexOffset: Offset a flexbox item in its parent container flow layout
<div></div>
fxFlexAlign: Works like fxLayoutAlign, but applies only to a single flexbox item, instead of all of them
<div></div>
fxFlexFill:
Maximizes width and height of element in a layout container
<div></div>
gdArea: Marks the element as a CSS Grid area
<div></div>
gdColumn: Specifies a grid item’s size and location within the grid column
<div></div>
gdRow: Specifies a grid item’s size and location within the grid row
<div></div>
gdGridAlign: Aligns a grid item within its container element
<div></div>
Responsive API
Responsive layouts in Material Design adapt to any possible screen size. Google’s specifications provide guidance that includes a flexible grid that ensures consistency across layouts, breakpoint details about how content reflows on different screens, and a description of how an app can scale from small to extra-large screens.
Enhancing the Static API
Developers should consult the HTML Declarative API for specific Static API details, then simply extend the HTML markup usages by adding the responsive suffixes (as discussed below)!
Angular Layout will automatically handle all the details around listening for mediaQuery activations and applying the responsive values to the host DOM elements.
Responsive Features
Responsive Features
To extend the static API with responsive features, we will first associate specific breakpoint aliases with mediaQuery values.
MediaQueries and Aliases
We can associate breakpoints with mediaQuery definitions using breakpoint alias(es):
breakpoint mediaQuery
xs ‘screen and (max-width: 599px)’
sm ‘screen and (min-width: 600px) and (max-width: 959px)’
md ‘screen and (min-width: 960px) and (max-width: 1279px)’
lg ‘screen and (min-width: 1280px) and (max-width: 1919px)’
xl ‘screen and (min-width: 1920px) and (max-width: 5000px)’
lt-sm ‘screen and (max-width: 599px)’
lt-md ‘screen and (max-width: 959px)’
lt-lg ‘screen and (max-width: 1279px)’
lt-xl ‘screen and (max-width: 1919px)’
gt-xs ‘screen and (min-width: 600px)’
gt-sm ‘screen and (min-width: 960px)’
gt-md ‘screen and (min-width: 1280px)’
gt-lg ‘screen and (min-width: 1920px)’
Example of applying responsive api on static api for flex layout
If we combine the breakpoint alias with the static API, we can easily support responsive breakpoints using a simple markup convention:
The alias is used as suffix extensions to the static API HTML markup:
.=””
[.]=””
Below is an example usage of the Responsive Layout API:
<div>
<div></div>
<div>
<div></div>
<div></div>
<div></div>
</div>
<div></div>
</div>
In the markup above the HTML API directives use both static values and expression bindings; where the values are expressed as raw, percentage, or pixel values.
Note: numeric values not explicitly annotated as px, vw, or vh default to percentage values.
Breakpoint Activation Fallback Algorithm –Not Clear
When a breakpoint is activated and the hosting element does NOT have a responsive API defined for the newly activated breakpoint, the Flex-Layout responsive engine uses a fallback, descending-scan algorithm to determine the replacement activation value. The algorithm uses breakpoint priorities to sort activate breakpoints by descending-priority.
This algorithm searches:
For non-overlapping breakpoints: the search scans from smallest-to-largest breakpoint range to find the closest, matching activation value.
(xs, sm, md, lg, xl)
For overlapping breakpoints: the search scans from smallest-to-largest breakpoint range to find the closest, matching activation value.
(lt-sm, lt-md, lt-lg, lt-xl); where lt-xl is the largest range
(gt-xs, gt-sm, gt-md, gt-lg); where gt-xs is the largest range.
Developers should consider (highest priority to lowest priority) equates to (smallest range to largest range).
Consider the following responsive markup examples:
Example #1
<div> ... </div>
When the activated breakpoint is:
xl, then fallback to the default fxShow; so the div is shown
lg, then the div is hidden (since the value === ‘true’)
md, then fallback to the default fxShow; so the div is shown
sm, then fallback to the default fxShow; so the div is shown
xs, then the div is shown (since the value === ‘false’)
Example #2
<div> ... </div>
When the activated breakpoint is:
xl, then fallback to ‘gt-sm’ so the div sizing is 100%
lg, then fallback to ‘gt-sm’ so the div sizing is 100%
md, then fallback to ‘gt-sm’ so the div sizing is 100%
sm, then fallback to the default fxFlex=”50%”; so the div sizing is 50%
xs, then fallback to the default fxFlex=”50%”; so the div sizing is 50%
Example #3
screen shot 2019-01-01 at 7 00 56 pm
https://github.com/angular/flex-layout/wiki/Responsive-API
CSS Flex Layout links
https: //github.com/angular/flex-layout
https: //github.com/angular/flex-layout/wiki/Declarative-API-Overview
https: //github.com/angular/flex-layout/wiki/API-Documentation
https: //github.com/angular/flex-layout/wiki/Responsive-API
https: //tburleson-layouts-demos.firebaseapp.com/#/docs
API for DOM containers-fxLayout API
https://github.com/angular/flex-layout/wiki/fxLayout-API
The fxLayout directive should be used on DOM containers whose children should layout or flow as the text direction along the main-axis or the cross-axis.
<div>
<div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div>
</div>
or
<div> <div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div> </div>
fxLayout Options
Shown below are the supported fxLayout directive values and their resulting CSS stylings on the hosting element container:
Value Equivalent CSS '' (default) flex-direction: row row flex-direction: row row-reverse flex-direction: row-reverse column flex-direction: column column-reverse flex-direction: column-reverse
fxLayout Side-Effects
Changes to the fxLayout value will cause the following directives to update and modify their element stylings:
fxLayoutGap
fxFlex
fxLayoutAlign
API for DOM containers-fxLayout + wrap
fxLayout + wrap
By default, flex items will not wrap in their container. Formerly published as distinct directive, fxLayoutWrap was deprecated in favor of simply adding the wrap parameter as a secondary option to the fxLayout directive.
<div>
<div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div>
</div>
Note: when using wrap, developers must first specify the layout direction.
API for DOM containers-fxLayout + inline
fxLayout + inline
There are some instances where developers want to use the inline-flex CSS display property, instead of the default. Angular Layout provides this option by accepting a secondary argument to the fxLayout directive as follows:
<div>
<div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div>
</div>
Note: when using inline, developers must first specify the layout direction.
API for DOM containers-fxLayoutAlign API
The fxLayoutAlign directive should be used on DOM containers whose children should be aligned on the main and cross-axis (optional)
<div>
<div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div>
</div>
API for DOM containers-fxLayoutAlign API - Main-axis
horizantal axis like justify-content:center
API for DOM containers-fxLayoutAlign API - Cross -axis
vertical alignement :align-items: center; align-content: center
API for DOM containers-fxLayoutAlign Options
Shown below are the supported fxLayoutAlign directive values and their resulting CSS stylings on the hosting element container
<div>
<div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div>
</div>
Main Axis
Value Equivalent CSS
(default) justify-content: flex-start
start or flex-start justify-content: flex-start
center justify-content: center
end or flex-end justify-content: flex-end
space-around justify-content: space-around
space-between justify-content: space-between
space-evenly justify-content: space-evenly
Cross Axis (optional)
Value Equivalent CSS
(default) align-items: stretch; align-content: stretch
start or flex-start align-items: flex-start; align-content: flex-start
center align-items: center; align-content: center
end or flex-end align-items: flex-end; align-content: flex-end
space-around align-items: space-around; align-content: space-around
space-between align-items: space-between; align-content: space-between
stretch max-width: 100% if flex-direction: column; else max-height: 100%
baseline align-items: baseline; align-content: stretch
API for DOM containers-fxLayoutGap API
The fxLayoutGap directive should be used on to specify margin gaps on children within a flexbox container (e.g. nested within a fxLayout container). There is a secondary mode to enable a gutter system with a margin applied on the host element.
Default Mode
margin-right used when the parent container flex-direction == “row”
margin-bottom used when the parent container flex-direction == “column”
Note that the last child item will NOT have a margin gap specified; only the inside gaps are specified. Additionally, fxLayoutGap does not respond to reveresed flow directions: column-reverse or row-reverse are used.
Examples: Flex-Direction: Row <div> <div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div> </div> lg_1
<div> <div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div> </div> ---- Flex-Direction: Column <div> <div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div> </div> fxLayout_column
<div>
<div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div>
</div>
API for DOM containers-Using fxLayoutGap with Wrap
When using wrap with fxLayout to wrap rows or columns, developers should account for the gap sizes when specifying the child item sizes (using fxFlex).
API for DOM containers-Grid Mode - not clear
To use fxLayoutGap with a gutter system, simply append the suffix grid to any fxLayoutGap value. For instance:
<div> <div>Section 1</div> <div>Section 2</div> <div>Section 3</div> </div> This creates a gutter system by applying a margin to the host element and an inverse padding to each child. Other than this change, it works exactly as the default mode. It also takes flex-order and hidden elements into account, and has the same responsive abilities as the default mode.
Please note that unlike the standard gap functionality, fxLayoutGap with the grid keyword applies a padding to each child element to add the gutter, in addition to the margin on the host element.
API for DOM elements: -
HTML Allowed values fxFlex "" | px | % | vw | vh | , fxFlexOrder int fxFlexOffset % | px | vw | vh fxFlexAlign start | baseline | center | end fxFlexFill, fxFill gdArea string name for the area as defined in gdAreas gdColumn any valid value for grid-column gdRow any valid value for grid-row gdGridAlign
This is the primary content of the panel.
Action bar Actions may optionally be included at the bottom of the panel, visible only when the expansion is in its expanded state. This is the expansion titleThis is the primary content of the panel.
Click me Disabling a panel Expansion panels can be disabled using the disabled attribute. A disabled expansion panel can't be toggled by the user, but can still be manipulated programmatically. This is the expansion title This is a summary of the content{{item | json}}
Select Option
Textarea
Legacy form field sentiment_very_satisfied Hint
Standard form field sentiment_very_satisfied Hint
Fill form field sentiment_very_satisfied Hint
Outline form field sentiment_very_satisfied Hint
Basic mat-select
Favorite food {{food.viewValue}} -- TS import {Component} from '@angular/core'; interface Food { value: string; viewValue: string; } ``` /** * @title Basic select */ @Component({ selector: 'select-overview-example', templateUrl: 'select-overview-example.html', styleUrls: ['select-overview-example.css'], }) export class SelectOverviewExample { foods: Food[] = [ {value: 'steak-0', viewValue: 'Steak'}, {value: 'pizza-1', viewValue: 'Pizza'}, {value: 'tacos-2', viewValue: 'Tacos'} ]; } ```Basic native select
Cars Volvo Saab Mercedes AudiYou selected: {{selected}}
TS: import {Component} from '@angular/core'; ``` /** @title Select with 2-way value binding */ @Component({ selector: 'select-value-binding-example', templateUrl: 'select-value-binding-example.html', styleUrls: ['select-value-binding-example.css'], }) export class SelectValueBindingExample { selected = 'option2'; } ```mat-select
Favorite food {{food.viewValue}}Selected food: {{selectedValue}}
native html select
Favorite car {{car.viewValue}}Selected car: {{selectedCar}}
TS: import {Component} from '@angular/core'; interface Food { value: string; viewValue: string; } interface Car { value: string; viewValue: string; } ``` /** * @title Select in a form */ @Component({ selector: 'select-form-example', templateUrl: 'select-form-example.html', styleUrls: ['select-form-example.css'], }) export class SelectFormExample { selectedValue: string; selectedCar: string; ``` foods: Food[] = [ {value: 'steak-0', viewValue: 'Steak'}, {value: 'pizza-1', viewValue: 'Pizza'}, {value: 'tacos-2', viewValue: 'Tacos'} ]; cars: Car[] = [ {value: 'volvo', viewValue: 'Volvo'}, {value: 'saab', viewValue: 'Saab'}, {value: 'mercedes', viewValue: 'Mercedes'} ]; }mat select
Favorite animal -- {{animal.name}} Please choose an animal {{animalControl.value?.sound}}native html select
Select your car (required) Saab Mercedes Audi This field is required You can pick up your favorite car here TS: import {Component} from '@angular/core'; import {FormControl, Validators} from '@angular/forms'; interface Animal { name: string; sound: string; } ``` /** @title Select with form field features */ @Component({ selector: 'select-hint-error-example', templateUrl: 'select-hint-error-example.html', styleUrls: ['select-hint-error-example.css'], }) export class SelectHintErrorExample { animalControl = new FormControl('', Validators.required); selectFormControl = new FormControl('', Validators.required); animals: Animal[] = [ {name: 'Dog', sound: 'Woof!'}, {name: 'Cat', sound: 'Meow!'}, {name: 'Cow', sound: 'Moo!'}, {name: 'Fox', sound: 'Wa-pa-pa-pa-pa-pa-pow!'}, ]; } ``` --- here we are assinging the value of mat-select to the whole object instead of just value property {{animal.name}} as we want to read an attribute later {{animalControl.value?.sound}} other way to do the samething: Favorite animal -- {{animal.name}} Please choose an animal {{animalControl.value}}Disable select
```mat-select
Choose an option Option 1 Option 2 (disabled) Option 3native html select
Choose an option Volvo Saab Mercedes Audi TS: import {Component} from '@angular/core'; import {FormControl} from '@angular/forms'; ``` /** @title Disabled select */ @Component({ selector: 'select-disabled-example', templateUrl: 'select-disabled-example.html', styleUrls: ['select-disabled-example.css'], }) export class SelectDisabledExample { disableSelect = new FormControl(false); } ```Disable select
in ts: import {Component} from '@angular/core'; import {FormControl} from '@angular/forms'; ``` /** @title Disabled select */ @Component({ selector: 'select-disabled-example', templateUrl: 'select-disabled-example.html', styleUrls: ['select-disabled-example.css'], }) export class SelectDisabledExample { disableSelect = new FormControl(false); } ```mat-select
State None {{state}}native html select
Select your car Volvo Saab Mercedes Audi in TS: import {Component} from '@angular/core'; /** @title Select with reset option */ @Component({ selector: 'select-reset-example', templateUrl: 'select-reset-example.html', styleUrls: ['select-reset-example.css'], }) export class SelectResetExample { states: string[] = [ 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming' ]; }mat-select
Pokemon -- None -- {{pokemon.viewValue}}native html select
Cars volvo Saab Mercedes Audi TS: import {Component} from '@angular/core'; import {FormControl} from '@angular/forms'; interface Pokemon { value: string; viewValue: string; } ``` interface PokemonGroup { disabled?: boolean; name: string; pokemon: Pokemon[]; } ``` ``` /** @title Select with option groups */ @Component({ selector: 'select-optgroup-example', templateUrl: 'select-optgroup-example.html', styleUrls: ['select-optgroup-example.css'], }) export class SelectOptgroupExample { pokemonControl = new FormControl(); pokemonGroups: PokemonGroup[] = [ { name: 'Grass', pokemon: [ {value: 'bulbasaur-0', viewValue: 'Bulbasaur'}, {value: 'oddish-1', viewValue: 'Oddish'}, {value: 'bellsprout-2', viewValue: 'Bellsprout'} ] }, { name: 'Water', pokemon: [ {value: 'squirtle-3', viewValue: 'Squirtle'}, {value: 'psyduck-4', viewValue: 'Psyduck'}, {value: 'horsea-5', viewValue: 'Horsea'} ] }, { name: 'Fire', disabled: true, pokemon: [ {value: 'charmander-6', viewValue: 'Charmander'}, {value: 'vulpix-7', viewValue: 'Vulpix'}, {value: 'flareon-8', viewValue: 'Flareon'} ] }, { name: 'Psychic', pokemon: [ {value: 'mew-9', viewValue: 'Mew'}, {value: 'mewtwo-10', viewValue: 'Mewtwo'}, ] } ]; } ```mat-select
Choose one Clear Valid option Invalid option Errors appear instantly! You must make a selection Your selection is invalidnative html select
Choose one Valid option Invalid option You must make a selection Your selection is invalid TS: import {Component} from '@angular/core'; import {FormControl, FormGroupDirective, NgForm, Validators} from '@angular/forms'; import {ErrorStateMatcher} from '@angular/material/core'; ``` /** Error when invalid control is dirty, touched, or submitted. */ export class MyErrorStateMatcher implements ErrorStateMatcher { isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { const isSubmitted = form && form.submitted; return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted)); } } ``` /** @title Select with a custom ErrorStateMatcher */ @Component({ selector: 'select-error-state-matcher-example', templateUrl: 'select-error-state-matcher-example.html', styleUrls: ['select-error-state-matcher-example.css'], }) export class SelectErrorStateMatcherExample { selected = new FormControl('valid', [ Validators.required, Validators.pattern('valid'), ]); selectFormControl = new FormControl('valid', [ Validators.required, Validators.pattern('valid'), ]); nativeSelectFormControl = new FormControl('valid', [ Validators.required, Validators.pattern('valid'), ]); ``` matcher = new MyErrorStateMatcher(); } ``` A global error state matcher can be specified by setting the ErrorStateMatcher provider. This applies to all inputs. For convenience, ShowOnDirtyErrorStateMatcher is available in order to globally cause input errors to show when the input is dirty and invalid. ``` @NgModule({ providers: [ {provide: ErrorStateMatcher, useClass: ShowOnDirtyErrorStateMatcher} ] }) ```Completely disabled
Popup disabled
Input disabled
TS: import {Component} from '@angular/core'; /** @title Disabled datepicker */ @Component({ selector: 'datepicker-disabled-example', templateUrl: 'datepicker-disabled-example.html', styleUrls: ['datepicker-disabled-example.css'], }) export class DatepickerDisabledExample {}Options selected: {{shoes.selectedOptions.selected.length}}
TS: import {Component} from '@angular/core'; ``` /** * @title List with selection */ @Component({ selector: 'list-selection-example', styleUrls: ['list-selection-example.css'], templateUrl: 'list-selection-example.html', }) export class ListSelectionExample { typesOfShoes: string[] = ['Boots', 'Clogs', 'Loafers', 'Moccasins', 'Sneakers']; } ```Options selected: {{shoes.selectedOptions.selected.length}}
The options within a selection-list should not contain further interactive controls, such as buttons and anchors. as shown in the example).
```
{{message.from}}
{{message.subject}} -- {{message.content}}
```{{message.from}}
{{message.subject}}
{{message.content}}
{{message.from}}
{{message.subject}} -- {{message.content}}
```{{message.from}}
{{message.subject}} -- {{message.content}}
```Folders
folder{{folder.name}}
{{folder.updated}}
Notes
note{{note.name}}
{{note.updated}}
Folders
folder{{folder.name}}
{{folder.updated}}
Notes
note{{note.name}}
{{note.updated}}
Folders
folder{{folder.name}}
{{folder.updated}}
Notes
note{{note.name}}
{{note.updated}}
Default appearance: Bold Italic Underline
Legacy appearance: Bold Italic Underline
TS: import {Component} from '@angular/core'; /** * @title Button toggle appearance */ @Component({ selector: 'button-toggle-appearance-example', templateUrl: 'button-toggle-appearance-example.html', styleUrls: ['button-toggle-appearance-example.css'], }) export class ButtonToggleAppearanceExample {}