babel-plugin-angularjs-annotate icon indicating copy to clipboard operation
babel-plugin-angularjs-annotate copied to clipboard

Annotation doesn't work for a controller with name as a variable

Open EladBezalel opened this issue 8 years ago • 1 comments

And probably with any other .module api

I use webpack and angular

import angular from 'angular';

const MY_CONTROLLER = 'myController';

angular.module('myApp').controller(MY_CONTROLLER, $scope => {});

export default MY_CONTROLLER;

EladBezalel avatar Feb 08 '17 14:02 EladBezalel

There's some history here about why this is difficult: https://github.com/olov/ng-annotate/issues/22

In general, in this use-case (and all use-cases, really), I strongly recommend using the explicit 'ngInject'; prologue directives (and explicitOnly configuration option) to annotate your functions.

Also, in your specific example, I'd advise against using a lambda function for a controller declaration, as you'll have no way of accessing your controller's of this.

I'll leave this open, as it's something that we could hypothetically support some day. However, I want to lean on the side of caution when making any changes that could introduce false-positives.

schmod avatar Jul 12 '17 15:07 schmod