As the user types into an input field I want everything else than numbers to be replaced with an empty string. Unfortunately the app doesn't detect that the ngModel has changed and only updates the variable balanceAmount
when there is a number entered again.
Is there a possibility to tell Angular that the ngModel has changed and should be updated?
HTML:
<input [ngModel]="balanceAmount" (ngModelChange)="onBalanceChange($event)" />
Typescript:
onBalanceChange(amount) {
amount = amount.replace(/[^0-9\.]+/g, '');
this.balanceAmount = amount;
}