Closed
Description
When a directive uses a controller and that controller needs // @ngInject
syntax it is not being caught when it is defined within the directive closure.
(function () {
'use strict';
angular
.module('app')
.directive('foo', foo);
/**
* @returns {Object} - Directive definition object
*/
function foo() {
return {
restrict: 'EA',
scope: true,
transclude: false,
templateUrl: 'foo.html',
controller: FooCtrl
};
/**
* @ngInject
*/
function FooCtrl($scope) {
var vm = $scope.bar = {
timeFormat: 'H:mma'
};
}
}
}());
Yet this does work when I moved the controller outside the directive.
(function () {
'use strict';
angular
.module('app')
.directive('foo', foo);
/**
* @returns {Object} - Directive definition object
*/
function foo() {
return {
restrict: 'EA',
scope: true,
transclude: false,
templateUrl: 'foo.html',
controller: FooCtrl
};
}
/**
* @ngInject
*/
function FooCtrl($scope) {
var vm = $scope.bar = {
timeFormat: 'H:mma'
};
}
}());
Metadata
Metadata
Assignees
Labels
No labels