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.

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...