Equivalent to ng list in Angular 2

Having hardly found the documentation on this, but in Angular 1 you can do:

<textarea ng-model="name" ng-list=","></textarea> 

Then at the entrance, if you were to enter "Hello world!". name will be an array ["Hello", "world!"] .

My goal is to use ng-list with an HTML object &#10; to split a string textarea into a string into an array. See an example from the documentation .

Is there an equivalent to this in Angular 2?

+6
source share
1 answer

Could not find your own solution, but you can use (ngModelChange) and then get the parsed value as follows:

  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 problems with config.js ...)

+4
source

Source: https://habr.com/ru/post/1012792/


All Articles