angularjs文本区域字符计数器 [英] angularjs text area character counter
本文介绍了angularjs文本区域字符计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我有一个文本区域characeter计数器。我的问题是,它不计数空格或换行。我如何让这个它这样做?
< DIV CLASS =控制> &所述; textarea的行=4COLS =50最大长度=1500的数据-NG-的minLength =1数据纳克
模型=createprofilefields.description要求的亮点,导通
错误>< / textarea的> < BR /><! - 反 - >
<跨度类=形式的帮助> {{1500 createprofilefields.description.length}}
人物< / SPAN> < / DIV>
解决方案
这是因为angularJS自动修整模型。
如果你使用angularJS 1.1.1或更高版本,添加 NG-修剪=FALSE
到的textarea
。
的例子: http://jsfiddle.net/9DbYY/
Hi I have a characeter counter for a text area. My problem is that it doesn't count spaces or linebreaks. How do I make it so that it does so?
<div class="controls">
<textarea rows="4" cols="50" maxlength="1500" data-ng-minLength="1" data-ng
model="createprofilefields.description" required highlight-on-
error></textarea>
<br />
<!--counter-->
<span class="form-help">{{1500-createprofilefields.description.length}}
Characters</span>
</div>
解决方案
It's because angularJS automatically trimmed your model.
If you're using angularJS 1.1.1 or newer, add ng-trim="false"
to textarea
.
Working example: http://jsfiddle.net/9DbYY/
这篇关于angularjs文本区域字符计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文