在angularJS中使用angular-cached-resource的未知提供商

Unknown provider in angularJS with angular-cached-resource

本文关键字:未知 提供商 angular-cached-resource angularJS      更新时间:2023-09-26

我已经在我的angular应用程序中正确地添加了一个JS文件angular-cached-resource (https://github.com/goodeggs/angular-cached-resource),并试图实例化它:

angular.module('client.core.resources')
.factory('TranslationResource', ['$cachedResource', 'ConstantValueService', function ($cachedResource, ConstantValueService) {
    var localizationUrl = ConstantValueService.get('webApiUri') + '/api/localization/';

    // TODO adjust webapi to work.
    return $cachedResource('translationResource', localizationUrl, {lang: '@lang'},
        {
            getTranslationForCulture: {
                method: 'GET',
                isArray: true
            },
        });
}]);

但是我得到错误:

[$injector:unpr]未知提供商:$cachedResourceProvider <-$cachedResource <- TranslationResource <- TranslationService错误。

我可能做错了什么?

$cachedResource服务是ngCachedResource模块的一部分,因此为了使用它,你需要在你的应用程序中将ngCachedResource列为依赖项。

 angular.module('myApp',[...,'ngCachedResource'])....