Angularjs: Error: [ng:areq] Argument 'HomeController' is not a function, got undefined

前端 未结 24 1621
抹茶落季
抹茶落季 2020-11-27 12:22

This is my demo using angularjs, for creating a service file, and adding service to a controller.

I have two problems with my demo:

  • One is when I put <
24条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 12:42

    Error: ng:areq Bad Argument has gotten me a couple times because I close the square bracket too soon. In the BAD example below it is closed incorrectly after '$state' when it should actually go before the final parenthese.

    BAD:

    sampleApp.controller('sampleApp', ['$scope', '$state'], function($scope, $state){
    
    });
    

    GOOD:

    sampleApp.controller('sampleApp', ['$scope', '$state', function($scope, $state){
    
    }]);
    

提交回复
热议问题