[英]Why am I getting “ReferenceError: $cacheFactory is not defined”
When ever I try to run this plunkr code it throws error (see console log). 每当我尝试运行此plunkr代码时,都会引发错误(请参阅控制台日志)。
http://plnkr.co/edit/I0FsK2S30gfNUhlkKwcB?p=preview http://plnkr.co/edit/I0FsK2S30gfNUhlkKwcB?p=preview
I am trying to set $httpProvider.defaults.cache
here with a default capacity. 我试图在这里将$httpProvider.defaults.cache
设置$httpProvider.defaults.cache
默认容量。
Firstly you are not injecting $cacheFactory
into your config, that is why you are getting 'undefined'. 首先,您没有将$cacheFactory
注入配置中,这就是为什么您得到“未定义”的原因。 However if you do inject it into your config, your error will change to 'Unknown Provider'. 但是,如果确实将其注入到配置中,则错误将变为“未知提供程序”。 This is because the config section of angular will only accept injected providers. 这是因为angular的config部分将仅接受注入的提供程序。
From here: https://docs.angularjs.org/guide/module 从这里: 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
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.