AngularJS未知提供者cookieReader [英] AngularJS unknown provider cookieReader
问题描述
我试图使用AngularJS翻译。我遇到的问题是,我得到未知的提供者:$$ cookieReaderProvider < - $$ cookieReader < - $ cookies< - $ cookieStore< - $ translateCookieStorage< - $ translate< - $ cookies
错误时尝试使用 $ translateProvider.useCookieStorage();
I'm trying to use AngularJS translations. The problem I encountered is that I'm getting Unknown provider: $$cookieReaderProvider <- $$cookieReader <- $cookies <- $cookieStore <- $translateCookieStorage <- $translate <- $cookies
error when trying to use $translateProvider.useCookieStorage();
我在应用程式中插入了 ngCookies
:
I've injected ngCookies
as a dependency in my app:
var nfqApp = angular.module('myApp', ['postServices', 'angularFileUpload', 'ngSanitize', 'ui.date',
'bootstrapLightbox', 'profileServices', 'ngRoute', 'angularMoment', 'pascalprecht.translate', 'ngCookies']);
我还按照以下顺序添加了与翻译和Cookie相关的以下文件:
I've also included following files related to translations and cookies in the following order:
- angular-translate.min.js
- angular-cookies.js
- angular-translate-interpolation-messageformat.js
- angular-translate-storage-cookie.js
- messageformat.js
- en.js
- lt.js
- angular-translate.min.js
- angular-cookies.js
- angular-translate-interpolation-messageformat.js
- angular-translate-storage-cookie.js
- messageformat.js
- en.js
- lt.js
我尝试使用cookieStorage:
My app config (where I try to use cookieStorage:
myApp.config(['$translateProvider', function ($translateProvider) {
$translateProvider.translations('lt', {
"OTHER_LIKES" : "{peopleCount, plural, one {# kolega tai mėgsta} few {# kolegos tai mėgsta} other {# kolegų tai mėgsta}}",
"YOU_AND_OTHERS_LIKES" : "{peopleCount, plural, one {Tu ir # kolega tai mėgsta} few {Tu ir # kolegos tai mėgsta} other {Tu ir # kolegų tai mėgsta}}",
"YOU_LIKE" : "Tu mėgsti tai"
});
$translateProvider.translations('en', {
"OTHER_LIKES" : "{peopleCount, plural, one {# colleague likes this} few {# colleagues likes this} other {# colleagues likes this}}",
"YOU_AND_OTHERS_LIKES" : "{peopleCount, plural, one {You and # colleague likes this} few {You and # colleagues likes this} other {You and # colleagues likes this}}",
"YOU_LIKE" : "You like this"
});
$translateProvider.preferredLanguage('lt');
$translateProvider.fallbackLanguage('en');
$translateProvider.addInterpolation('$translateMessageFormatInterpolation');
$translateProvider.useCookieStorage();
}]);
推荐答案
我发现我使用angular-cookies。 js设计为不同版本的角。将它们更新到相同的版本解决了问题。使用AngularJS v1.4.1。
I found out that I was using angular-cookies.js designed for different version of angular. updating them both to the same version solved the problem. AngularJS v1.4.1 was used.
这篇关于AngularJS未知提供者cookieReader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!