AngularJS controllers and “use strict”

前端 未结 4 729
野趣味
野趣味 2021-02-01 16:18

I recently started using JSHint and it is requiring me to use the function form of \"use strict\". Since then, AngularJS throws an error:

\"Error: Argument \'webAddressC

4条回答
  •  故里飘歌
    2021-02-01 17:09

    Another way to do what @pkzolowski is doing if your angular module is already loaded elsewhere:

    var app = angular.module('myApp');
    app.controller(...);
    app.service(...);
    ...
    

    It is based on the comment from here: angularjs defining services for the same module in different files

    Beware that using angular.module('myModule', []) will create the module myModule and overwrite any existing module named myModule. Use angular.module('myModule') to retrieve an existing module.

提交回复
热议问题