Reputation: 81
I have this problem when i use Grunt-jshint.
i have an Angular app, and i define my controller or directive as:
angular.module('myApp').controller('beerFormController', beerForm_controller);
beerForm_controller.$inject = ['$scope'];
function beerForm_controller($scope) {
var vm_main = this;
vm_main.smsCgHijo = 'some text here';
}
and this is the error that i have after start my grunt task:
Running "jshint:files" (jshint) task
Linting app/js/directives/beerForm/beerForm_controller.js...ERROR
[L7:C29] 'beerForm_controller' was used before it was defined.
Can somebody help me ?
What is problem?... Thanks
Upvotes: 0
Views: 436
Reputation: 165941
The problem, as stated by the message, is that you've used the beerForm_controller
function before it appears in the source. This is not actually a problem because function declarations are hoisted but it violates the default JSHint style guide.
You can tell JSHint to allow that style by setting the latedef
option to nofunc
.
Upvotes: 1