mat input change event angular 6 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: mat-select onchange event
<mat-form-field>
<mat-select placeholder="State" (selectionChange)="someMethod($event.value)">
<mat-option *ngFor="let state of states" [value]="state.value">
{{ state.viewValue }}
</mat-option>
</mat-select>
</mat-form-field>