Here is one of the versions that I tried INSIDE TEXTAREA: (change)="dosomething($event)"
and it's not doing anything. What is the directive for "change"?
ngModelChange It fires when the model changes. You cannot use this event without ngModel directive. change triggers when the user changes the input. ngModelChange triggers when the model changes, irrespective of that change is caused by the user or not.
NgModelChange is an Angular specific event, which we can use to listen for changes to the user input. It is the @Output property of the ngModel directive, Hence we need to use it along with it. ngModle raises the NgModelChange event, whenever the model changes.
They provide data-binding, which means they are part of the AngularJS model, and can be referred to, and updated, both in AngularJS functions and in the DOM. They provide validation. Example: an <textarea> element with a required attribute, has the $valid state set to false as long as it is empty.
You should be using ngModelChange
<textarea cols="25" [ngModel]="data" (ngModelChange)="doSomething($event)"></textarea>
LIVE DEMO
Update:
(change)
event will work in textarea but it is triggered on blur and text changed inside the text area
DEMO
(change) didn't work for me neither, try (input) it worked perfectly :
<textarea [(ngModel)]="mytext" (input)="autoGrow($event)"></textarea>
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