Ole Ersoy

Image by Gleb Korovko from Pixabay

Scenario

Within our app component we wish to add a onValid CSS class whenever the _valid property on the component is true.

Approach

Within styles.css create the onValid CSS class.

.onValid {
color: aqua;
}

Decorate a isValid() getter with @HostBinding that will add the onValid CSS class to the component whenever the _valid property is true.

@HostBinding('class.onValid')
get isValid() {
return this._valid;
}
private _valid = true;

Demo

--

--

Image by donations welcome from Pixabay

Scenario

We want to use a ternary expression in SASS.

This would allow us to for example initialize a default variable when a value is not defined liked this (Taken from the Angular define-palette) .

warn: if($warn != null, $warn, define-palette(palette.$red-palette)),

Approach

The evaluation of the below expression will set $result to…

--

--

--

--