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 ...)
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.