I have textarea. I try to restrict width of value to 10 symbols. I am trying to cut value on input event.
<textarea [(ngModel)]="smsMessage" (input)="changeSMSMessage()"></textarea>
changeSMSMessage() {
this.smsMessage = this.smsMessage.substr(0, 10);
console.log(this.smsMessage);
}
But it doesn't work. I see that value was cut in changeSMSMessage() method, but on UI I see not changed value.
Plunker
When I changed event from input to keyup, it starts work properly. All characters after the tenth are deleted.
So, could someone explain why is input event doesn't update value in textarea?
maxlength="10"attribute which will not allow user to type more than 10 symbols