ngchange angular code example
Example 1: ngmodel onchange
(ngModelChange)="onModelChange()"
Example 2: ngchange angular 8
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<input type="number" [ngModel]="percent" (ngModelChange)="onPercentChange($event)" />
`,
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
percent = 20;
onPercentChange(percent: number) {
console.log('here');
this.percent = percent;
}
}
Example 3: angular ngclass
content_copy
<some-element [ngClass]="'first second'">...</some-element>
<some-element [ngClass]="['first', 'second']">...</some-element>
<some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
<some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
<some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
Example 4: Angular forkjoin
forkJoin([
getData1(),
getData2()
]).subscribe(([response1, response2]) => {
});