我正在按照本教程进行操作,并相应地创建了自定义过滤器下方。然而,最后一个导致第一个消失。当您使用truncate
过滤器时,它是一个例外。如何在一个模块中创建多个过滤器?
angular.module('filters', []).filter('truncate', function () {
return function (text, length, end) {
if (isNaN(length))
length = 10;
if (end === undefined)
end = "...";
if (text.length <= length || text.length - end.length <= length) {
return text;
}
else {
return String(text).substring(0, length-end.length) + end;
}
};
});
angular.module('filters', []).filter('escape', function () {
return function(text) {
encodeURIComponent(text);
};
});
angular.module('filters', []).filter("truncate", function() {})
.filter("escape", function() {});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句