Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-list with line break as textarea delimter in AngularJS >1.3

I'm using AngularJS 1.3 where the syntax for ng-list has changed slightly (for instance, it no longer supports regex)

I'm trying to specify a line break as the delimiter for ng-list in a textarea. However it doesn't work properly. I've tried to set ng-list to ASCII line break




but then there is a problem. At once when the contents are edited (i.e. add one character to the textarea contents), it starts to break on every single character.

How do I properly specify a line break as the delimiter for ng-list in AngularJS 1.3?

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

like image 564
Svein Fidjestøl Avatar asked Oct 19 '14 12:10

Svein Fidjestøl


1 Answers

We should 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 the doc ngList (small cite:)

If ngTrim is set to "false" then whitespace around both the separator and each list item is respected. This implies that the user of the directive is responsible for dealing with whitespace but also allows you to use whitespace as a delimiter, such as a tab or newline character.

like image 158
Radim Köhler Avatar answered Nov 06 '22 04:11

Radim Köhler