Closed ceoaliongroo closed 9 years ago
Can you provide input, expected output, actual output and ng-annotate version?
__ng-annotate:__ version 0.10.3
using __grunt-ng-annotate:__
version 0.4.0.
input:
...
controllerProvider: function(condition, $stateParams) {
switch (condition) {
case 'condition-1':
return function($state) {
$state.go('logout', {}, {reload: true});
};
case 'condition-2':
return function($state) {
$state.go('dashboard', {param1: true});
};
default:
return $stateParams.param1 + 'Controller';
}
},
...
expected output:
...
controllerProvider: ['condition', '$stateParams', function(condition, $stateParams) {
switch (condition) {
case 'condition-1':
return ['$state', function($state) {
$state.go('logout', {}, {reload: true});
}];
case 'condition-2':
return ['$state', function($state) {
$state.go('dashboard', {param1: true});
}];
default:
return $stateParams.param1 + 'Controller';
}
}],
...
Next time please test using the latest version of ng-annotate, 0.10.3 was released almost a year ago. Upgrade to the latest grunt-ng-annotate version and you should get up to date with ng-annotate too.
In either case, from what I understand of your proposed transformation it's much too complicated to carry its weight in ng-annotate. I recommend you to do this:
return function($state) {
"ngInject";
$state.go('logout', {}, {reload: true});
};
Inside a
state
ofui-router
, is missing theng-annotation
. Example (for$state
) :