我正在使用AngularJS 1.3,其中ng-list的语法略有改变(例如,它不再支持正则表达式)
我正在尝试将一个换行符指定为textarea中ng-list的分隔符.但它无法正常工作.我试图将ng-list设置为ASCII换行符
但后来出现了问题.在编辑内容时(即将一个字符添加到textarea内容中),它会立即在每个字符上中断.
如何在AngularJS 1.3中正确指定换行符作为ng-list的分隔符?
解决方法
我们应该使用ng-trim =“false”.见更新
plunker
<textarea name="namesInput" ng-list=" " ng-model="names" ng-trim="false" required cols="40" rows="20"></textarea>
参见doc 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.