UNPKG

angular-filter

Version:

Bunch of useful filters for angularJS(with no external dependencies!)

26 lines (22 loc) 570 B
/** * @ngdoc filter * @name map * @kind function * * @description * Returns a new collection of the results of each expression execution. */ angular.module('a8m.map', []) .filter('map', ['$parse', function($parse) { return function (collection, expression) { collection = isObject(collection) ? toArray(collection) : collection; if(!isArray(collection) || isUndefined(expression)) { return collection; } return collection.map(function (elm) { return $parse(expression)(elm); }); } }]);