标签:ext angular label 过滤器 last tail mod angularjs set
1.控制文本长度,超出省略号
在模版中:
<label>{{item.abbr| cut:true:20:‘ ...‘ }}<label>
js:
angular.module(‘app‘).filter(‘textLengthSet‘, function() {
return function(value, wordwise, max, tail) {
if (!value) return ‘‘;
max = parseInt(max, 10);
if (!max) return value;
if (value.length <= max) return value;
value = value.substr(0, max);
if (wordwise) {
var lastspace = value.lastIndexOf(‘ ‘);
if (lastspace != -1) {
value = value.substr(0, lastspace);
}
}
return value + (tail || ‘ …‘);//‘...‘可以换成其它文字
};
});
标签:ext angular label 过滤器 last tail mod angularjs set
原文地址:http://www.cnblogs.com/leepyng/p/6003447.html