olov / ng-annotate

Add, remove and rebuild AngularJS dependency injection annotations
MIT License
2.03k stars 152 forks source link

Doesn't annotate module().decorator #204

Closed mattlewis92 closed 8 years ago

mattlewis92 commented 8 years ago

Angular 1.4 introduced a new decorator helper with the pattern:

angular
  .module('moduleName', [])
  .decorator('serviceName', function($delegate, and, other, injectables) {
  });

However it's not currently automatically annotated.

yggie commented 8 years ago

having the same problem, I had to remove the decorator from the chain otherwise ng-annotate ignores the module entirely:

var app = angular.module('moduleName', []);

app.decorator('serviceName', [/* service names */ function(/* services */) {
});
fracz commented 8 years ago

+1

As a temporal solution, you can mark the function to be annotated with

app.decorator('serviceName', function($delegate, and, others) {
  'ngInject';
  // decorator code
  return $delegate;
});
olov commented 8 years ago

See more info for why this has been the case in #82. I'll change the code to support foo.decorator("yo", function() ...) generically with an exception for $stateProvider.decorator(...) instead. Will be out in next release.

olov commented 8 years ago

released in 1.1.0