Ng-list with line break as textarea delimiter in AngularJS> 1.3

I am using AngularJS 1.3, where the syntax for ng-list has changed a bit (for example, it no longer supports regular expression)

I am trying to specify a line break as a delimiter for ng-list in a text box. However, this does not work properly. I tried setting ng-list to ASCII line break


 

but then there is a problem. Immediately after editing the content (i.e., adding one character to the contents of the text area), it begins to break into each individual character.

How to correctly specify line break as a separator for an ng list in AngularJS 1.3?

Link to the plunker: http://plnkr.co/edit/F37yA0LRHQXMh4caP3A0

+6
source share
1 answer

We must use ng-trim="false" . See Updated plunker

  <textarea name="namesInput" ng-list="&#10;" ng-model="names" ng-trim="false" required cols="40" rows="20"></textarea> 

See ngList document (small cite :)

If ngTrim is set to false, then spaces around the separator and each list item are respected. This implies that the user of the directive is responsible for working with spaces, but also allows you to use spaces as a separator, for example, a tab or a newline.

+12
source

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


All Articles