Categories
Angular.js

angular.js filters

Creating one:

.filter('truncate', function(){
  return function(input, limit){
    return (input.length > limit) ? input.substr(0, limit)+'…' : input;
  };
})

The first argument in the returning function is the input data we are filtering on, we can add any number of arguments after that.

See it in action here

Leave a Reply

Your email address will not be published. Required fields are marked *