angular-underscore
angular-underscore copied to clipboard
Sorry but...
You could just do:
myApp.filter('_', function(){
return function() {
var args = Array.prototype.slice.call(arguments, 0);
var method = args.splice(1,1)[0];
return _[method].apply(this, args);
}
});
angular.forEach(_, function(method, name){
// prefix all filters with '_' to prevent clobbering (such as $filter('filter') )
myApp..filter('_'+name, function(){
return method;
});
});
Demo: http://plnkr.co/edit/Jq1Lg5v1GquxnqHe5hj2?p=preview
Thank you for your advice, but not every underscore's method would be a proper filter, and some angular filter's use conventions could be merged with underscore, you could read the usage of filter in both angular and underscore, I have merged them together.