微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 带有换行符的ng-list,作为AngularJS中的textarea分隔符> 1.3

我正在使用AngularJS 1.3,其中ng-list的语法略有改变(例如,它不再支持正则表达式)

我正在尝试将一个换行符指定为textarea中ng-list的分隔符.但它无法正常工作.我试图将ng-list设置为ASCII换行符




但后来出现了问题.在编辑内容时(即将一个字符添加到textarea内容中),它会立即在每个字符上中断.

如何在AngularJS 1.3中正确指定换行符作为ng-list的分隔符?

链接到plunker:http://plnkr.co/edit/F37yA0LRHQXMh4caP3A0

解决方法

我们应该使用ng-trim =“false”.见更新 plunker
<textarea name="namesInput" 
 ng-list="&#10;"
 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.

原文地址:https://www.jb51.cc/js/155822.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐