gpt4 book ai didi

javascript - 为什么我收到 "ReferenceError: $cacheFactory is not defined"

转载 作者:行者123 更新时间:2023-11-28 06:56:17 26 4
gpt4 key购买 nike

每当我尝试运行这个 plunkr 代码时,它都会抛出错误(请参阅控制台日志)。

http://plnkr.co/edit/I0FsK2S30gfNUhlkKwcB?p=preview

我尝试在此处设置默认容量$httpProvider.defaults.cache

最佳答案

首先,您没有将 $cacheFactory 注入(inject)您的配置中,这就是您得到“未定义”的原因。但是,如果您确实将其注入(inject)到您的配置中,您的错误将更改为“未知提供商”。这是因为 Angular 的配置部分只接受注入(inject)的提供程序。

从这里: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
});

关于javascript - 为什么我收到 "ReferenceError: $cacheFactory is not defined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32545101/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com