GitHub 博客园 Nanakon

filter

说说AngularJS中的filter

name | maxLenFilter:30

angular.module("app.core").filter("maxLenFilter", function() {
    return function(input, length) {
        length = length || 20
        if (input.length > length) {
            return input.slice(0, length) + '...'
        } else {
            return input
        }
    }
})

 

posted on 2017-11-09 14:39  jzm17173  阅读(93)  评论(0编辑  收藏  举报

导航

轻音