Having a difficulty finding documentation on this, but in Angular 1 you could do:
<textarea ng-model="name" ng-list=","></textarea>
Then on input, if you were to enter "Hello, world!" name
would be an array of ["Hello", "world!"]
.
My goal is to use ng-list
with the HTML entity
for breaking a textarea
by line into an array. See example from docs.
Is there an equivalent of this in Angular 2?
Could not find native solution, but you can use (ngModelChange)
and then get the parsed value like this:
parseTextArea() {
this.textareaParsed = this.textarea.split("\n");
}
and in your template:
<textarea [(ngModel)]="textarea" (ngModelChange)="parseTextArea()"></textarea>
See this plunker: textarea example (in Chrome, IE has some issues with config.js...)
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