Why can't I get a $location injected into in my config()?

后端 未结 2 405
既然无缘
既然无缘 2021-02-05 04:35

Why does this give me an error:

angular.module(\'app\')
       .config(function($routeProvider, $locationProvider, $httpProvider, $location) {
2条回答
  •  情话喂你
    2021-02-05 04:54

    there are two module level ways to inject code:

    1) config. This method will run before the injectors are created, and only accepts providers and constants for injection

    2) run. This method will run during the app initialization phase and accepts only instances and constants (such as $location).

    factory (and service, controller, and directive) are functions which are part of your application. As such they too can only accepts instances(or singletons) and constants.

提交回复
热议问题