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

我与影子孤独终老i 提交于 2019-12-10 04:03:53

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/26450445/ng-list-with-line-break-as-textarea-delimter-in-angularjs-1-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!