当我尝试运行此 plunkr 代码时,它会引发错误(请参阅控制台日志)。
http://plnkr.co/edit/I0FsK2S30gfNUhlkKwcB?p=preview
我正在尝试在$httpProvider.defaults.cache
此处设置默认容量。
当我尝试运行此 plunkr 代码时,它会引发错误(请参阅控制台日志)。
http://plnkr.co/edit/I0FsK2S30gfNUhlkKwcB?p=preview
我正在尝试在$httpProvider.defaults.cache
此处设置默认容量。
首先,您没有注入$cacheFactory
到您的配置中,这就是您得到“未定义”的原因。但是,如果您确实将其注入到您的配置中,您的错误将更改为“未知提供者”。这是因为 Angular 的配置部分只接受注入的提供者。
从这里:https ://docs.angularjs.org/guide/module
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 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 run blocks
});