我已经在我的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'])....