我已经在我的 Angular 应用程序中正确地为 Angular 缓存资源(https://github.com/goodeggs/angular-cached-resource)添加了一个 JS 文件,并试图实例化它:
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] Unknown provider: $cachedResourceProvider <- $cachedResource <- TranslationResource <- TranslationService error.
我可能弄错了什么?
最佳答案
$cachedResource
服务是 ngCachedResource
模块的一部分,因此为了使用它,您需要将 ngCachedResource
列为依赖项应用程序。
angular.module('myApp',[...,'ngCachedResource'])....
关于javascript - 具有 Angular 缓存资源的angularJS中的未知提供者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25121538/