angular限制字符超过一定的字数隐藏字数显示省略号
自定义一个过滤器js代码function CarouselContentFilter () {return function (str) {if(str){var carContent = '';if(str.length >= 50){str.length = 5...
·
自定义一个过滤器
js代码
function CarouselContentFilter ( ) {
return function (str) {
if(str){
var carContent = '';
if(str.length >= 50){
str.length = 50;
carContent = str.substring(0,50) + '...';
}
else {
carContent = str
}
return carContent
}
}
}
然后配置过滤器
angular
.module('jibao')
.filter('CarouselContentFilter',CarouselContentFilter);
如果想在controller中使用自定义的过滤器,首先在controller中注入过滤器模块名称 如:CarouselContentFilter
html代码
<div class="ani title jb_carousel_content">
{{img.configXml.content | CarouselContentFilter}}
</div>


想要整理更多的碎片知识,扫码关注下面的公众号,让我们在哪里接着唠!

更多推荐
所有评论(0)