Does jshint understand Angular?

后端 未结 4 1417
甜味超标
甜味超标 2020-12-15 04:54

jshint is throwing an error when defining an angular module (or directive, or factory) as recommended by the Angular style guides (by John Papa or Todd Motto). For example,

4条回答
  •  生来不讨喜
    2020-12-15 05:27

    well first of include angular in your "globals variables", for example:

    "globals": { // Global variables.
            "jasmine": true,
            "angular": true,
            "browser": true,
            "element": true,
            "by":true,
            "io":true,
            "_":false,
            "$":false
        }
    

    then move your function definition before you reference it from angular.

    (function () {
        'use strict';
    
        function theController() {...}
    
        angular
            .module('myApp')
            .controller('myAppCtrl', theController);
    })();
    

提交回复
热议问题