AngularJS& gt; 1.3中带有换行符的ng-list作为textarea delimter [英] ng-list with line break as textarea delimter in AngularJS >1.3
问题描述
我正在使用AngularJS 1.3,其中ng-list的语法略有变化(例如,它不再支持正则表达式)
I'm using AngularJS 1.3 where the syntax for ng-list has changed slightly (for instance, it no longer supports regex)
我正在尝试将换行符指定为textarea中ng-list的定界符.但是,它不能正常工作.我尝试将ng-list设置为ASCII换行符
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.
在AngularJS 1.3中,如何正确地将换行符指定为ng-list的分隔符?
How do I properly specify a line break as the delimiter for ng-list in AngularJS 1.3?
链接到插件: http://plnkr.co/edit/F37yA0LRHQXMh4caP3A0
推荐答案
我们应使用 ng-trim ="false"
.查看更新的 plunker
<textarea name="namesInput"
ng-list=" "
ng-model="names"
ng-trim="false"
required cols="40" rows="20"></textarea>
请参阅文档 ngList (小引用:)
如果 ngTrim 设置为"false",则将尊重分隔符和每个列表项周围的空格.这意味着该指令的用户负责处理空格,但也允许您将空格用作定界符,例如制表符或换行符.
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.
这篇关于AngularJS& gt; 1.3中带有换行符的ng-list作为textarea delimter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!