olov / ng-annotate

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

Need to rename services based on convention #249

Closed ltvan closed 7 years ago

ltvan commented 8 years ago

I'm working on a project which the service proxy is generated with the name like this: `abp.services.app.serviceName' http://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API#DocAngularSupport

Currently I'm using a little hack:

var ngAnnotatePlugin = {
  init: function (ctx) {
    ctx.rename = {
      get: function (name) {
        if (/AppService$/.test(name)) {
          return 'abp.services.app.' + name.replace('AppService', '')
        }
        return name
      }
    }
  },
  match: function (node) {
  }
}

I'm looking for the ability to pass a callback/plugin to rename services.

Thanks.

ltvan commented 8 years ago

Or, something like this is more convenient if we have some services which does not follow any convention:

/* @ngInject { userService: 'abp.services.app.user', something:'some-thing' } */
olov commented 7 years ago

245