我使用的是 AngularJS 1.3,其中 ng-list 的语法略有变化(例如,它不再支持正则表达式)
我正在尝试指定一个换行符作为文本区域中 ng-list 的分隔符。但是它不能正常工作。我尝试将 ng-list 设置为 ASCII 换行符
但是问题来了。当内容被编辑时(即向文本区域内容添加一个字符),它开始在每个字符处中断。
如何在 AngularJS 1.3 中正确指定换行符作为 ng-list 的分隔符?
plunker 链接: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 (小引用:)
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.
关于javascript - ng-list with line break as textarea delimiter in AngularJS >1.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26450445/