Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

Sorry but... #5

Open
ProLoser opened this issue Mar 21, 2013 · 1 comment
Open

Sorry but... #5

ProLoser opened this issue Mar 21, 2013 · 1 comment

Comments

@ProLoser
Copy link

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

@floydwch
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants