I am trying to substract input value on focousout by 1. The strange problem is that it does the first time when I enter 100 and click aside(I get in view 99), but the second time I enter 100, it doesn't change although I can see in debug mode that the num property has been changed.
For this purpose I am just using one way binding and focusout event.
In html:
<input type="text" #numElement [ngModel]="num"
(focusout)="distractByOne(numElement.value)" />
In Component:
distractByOne(val) {
this.num = +val-1;
}
have you tried with ..
<input type="text" #numElement [ngModel]="num"
(focusout)="distractByOne($event)" />
In Component:
distractByOne(val) {
this.num = +val-1;
}
Hope it helps you ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.