每当我尝试运行这个plunkr代码时,它都会抛出错误(参见控制台日志)。
http://plnkr.co/edit/I0FsK2S30gfNUhlkKwcB?p =
预览我正在尝试将$httpProvider.defaults.cache
设置为默认容量。
首先,您没有将$cacheFactory
注入到您的配置中,这就是为什么您得到'未定义'。然而,如果你把它注入到你的配置中,你的错误会变成"未知的提供者"。这是因为angular的config部分只接受注入的提供商。
从这里: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
});