简体   繁体   English

为什么收到“ ReferenceError:未定义$ cacheFactory”

[英]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.

相关问题 为什么我得到一个ReferenceError:未定义 - Why am I getting a ReferenceError: not defined 为什么我得到“ReferenceError:getElementById未定义”? - Why am I getting “ReferenceError: getElementById is not defined”? 为什么我在 AngularJS 中收到错误“ReferenceError:类别未定义”? - Why am I getting an error, "ReferenceError: categories is not defined" in AngularJS? 为什么会出现“ Uncaught ReferenceError:未定义userId”错误? - Why am I getting “Uncaught ReferenceError: userId is not defined” error? 我为什么会收到“ Uncaught ReferenceError:未定义反应” - Why am I getting “Uncaught ReferenceError: React not defined” 为什么我得到:Uncaught ReferenceError: response is not defined - why am i getting: Uncaught ReferenceError: response is not defined 为什么我收到ReferenceError:框未定义错误 - Why am I getting ReferenceError: boxes is not defined error Vue/Vuetify:为什么我会收到一个 ReferenceError:变量未定义? - Vue/Vuetify: why am I getting a ReferenceError: variable is not defined? 为什么我得到 Uncaught ReferenceError: React is not defined? - Why am I getting Uncaught ReferenceError: React is not defined? 为什么我会收到此错误 ReferenceError: channel is not defined - Why am i getting this error ReferenceError: channel is not defined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM