I have this scenario: expecting an user's input and use that to _http.get() from server.
I have tried using keyup event, but can't manage. Any recommendation is much appreciated.
My template:
<div class="col-md-8">
<input type="text" class="form-control" [(ngModel)]="workOrder" (keyup)="populate()" placeholder="{{ 'FIELDS.PMS_IFR_WO' | translate }}"/>
</div>
My ts file:
populate(){
console.log(this.workOrder);
this._lookup.getIcrData().subscribe(res => {
console.log(res);
});
}
You are looking for ngModelChange:
<div class="col-md-8">
<input type="text" class="form-control" [ngModel]="workOrder" (ngModelChange)="populate($event)" placeholder="{{ 'FIELDS.PMS_IFR_WO' | translate }}"/>
</div>
Component
populate(value: any){
console.log(value);
this._lookup.getIcrData().subscribe(res => {
console.log(res);
});
}
ngModelChange is usually a good option
<input type="text" class="form-control"
[(ngModel)]="workOrder"
(ngModelChange)="populate()"
placeholder="{{ 'FIELDS.PMS_IFR_WO' | translate }}"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With