为什么这给我一个错误:
angular.module('app').config(function($routeProvider,$locationProvider,$httpProvider,$location) {
Uncaught Error: Unknown provider: $location from app
但这行不行?
angular.module("app").factory("SomeResource",function($q,$resource,$http,$location,AuthenticationService,Base64) {
这是同一个应用程序可以配置只能获得提供者,工厂只能获得非提供者?
只有提供者和常量可能被注入到配置块中。
原文链接:https://www.f2er.com/angularjs/145028.htmlFrom the angularjs 07000 on configuration blocks
Configuration blocks – get executed during the provider registrations and configuration phase. Only providers and constants can be injected into configuration blocks. This is to prevent accidental instantiation of services before they have been fully configured
Run blocks – get executed after the injector is created and are used to kickstart the application. Only instances and constants can be injected into run blocks. This is to prevent further system configuration during application run time.
配置块基本上是在将提供者注入控制器,服务,工厂等之前配置的地方。
angular.module('myModule',[]). config(function(injectables) { // provider-injector // This is an example of config block. // You can have as many of these as you want. // You can only inject Providers (not instances) // into the config blocks. }). run(function(injectables) { // instance-injector // This is an example of a run block. // You can have as many of these as you want. // You can only inject instances (not Providers) // into the run blocks });