angular-filter
Version:
Bunch of useful filters for angularJS(with no external dependencies!)
22 lines (20 loc) • 545 B
JavaScript
/**
* @ngdoc filter
* @name before
* @kind function
*
* @description
* get a collection and specified count, and returns all of the items
* in the collection before the specified count.
*/
angular.module('a8m.before', [])
.filter('before', function() {
return function (collection, count) {
collection = isObject(collection)
? toArray(collection)
: collection;
return (isArray(collection))
? collection.slice(0, (!count) ? count : --count)
: collection;
}
});