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
        }
    }
})
原文地址:https://www.cnblogs.com/jzm17173/p/7809283.html