[英]Why am I getting “ReferenceError: $cacheFactory is not defined”
每當我嘗試運行此plunkr代碼時,都會引發錯誤(請參閱控制台日志)。
http://plnkr.co/edit/I0FsK2S30gfNUhlkKwcB?p=preview
我試圖在這里將$httpProvider.defaults.cache
設置$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
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.