2015-06-16 10 views
15

mio principale definizione del modulo:

angular.module('app', ['app.animators', 
         'app.places', 
         'app.orders', 
         'app.excursions', 
         'app.events', 
         'app.hotel', 
         'app.controllers', 
         'app.services', 
         'angular-img-cropper', 
         'ui.router', 
         'templates', 
         'ngResource', 
         'ngCookies', 
         'ui.bootstrap', 
         'ngImgCrop', 
         'angularjs-dropdown-multiselect', 
         'uiGmapgoogle-maps']) 
    .config(['$httpProvider', '$locationProvider', '$stateProvider', '$urlRouterProvider', ($httpProvider, $locationProvider, $stateProvider, $urlRouterProvider) -> 
    $httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content') 

    $urlRouterProvider.otherwise("/admin/home") 

    $stateProvider.state('admin.services' 
     url: '/services' 
     controller: 'ServicesController' 
     templateUrl: 'services.html' 
    ).state('admin.home' 
     url: '/home' 
     templateUrl: 'home.html' 
    ).state('signIn' 
     url: '/admin/signin' 
     controller: 'SignInController' 
     templateUrl: 'signin.html' 
     resolve: 
     user: ['authService', '$q', (authService, $q) -> 
       $q.reject({ authorized : true }) if authService.currentUser() 
     ] 
    ).state('admin.signOut' 
     url: '/signout' 
     controller: 'SignOutController' 
    ).state('404' 
     url: '/404' 
     templateUrl: '404.html' 
    ).state('admin' 
     abstract: true 
     url: '/admin' 
     template: '<ui-view />' 
     resolve: 
     user: ['authService', '$q', (authService, $q) -> 
       $q.reject({ unAuthorized : true }) unless authService.currentUser() 
       ] 
    ) 

    $locationProvider.html5Mode(true) 
]) 

Anche in index.html è <script src="/assets/angular-cookies/angular-cookies.js?body=1">. Ottengo l'errore in questo modulo:

angular.module('app.services', []).factory('authService', ['SIGN_IN_ENDPOINT', 'SIGN_OUT_ENDPOINT', '$http', '$cookies', (SIGN_IN_ENDPOINT, SIGN_OUT_ENDPOINT, $http, $cookies) -> 
    auth = {} 
    auth.signIn = (credentials) -> 
     return $http.post(SIGN_IN_ENDPOINT, { user: credentials }) 
    auth.signOut = -> 
     return $http.delete(SIGN_OUT_ENDPOINT) 
    auth.currentUser = -> 
     $cookies.remember_token 

    auth 
]).value('SIGN_IN_ENDPOINT', "#{ location.protocol }//#{ location.host }/sign_in").value('SIGN_OUT_ENDPOINT', "#{ location.protocol }//#{ location.host }/sign_out") 
.factory("httpErrorInterceptorModule", ["$q", "$rootScope", "$location", ($q, $rootScope, $location) -> 
    success = (response) -> 
    return response; 

    error = (response) -> 
    if(response.status is 401) 
     $location.path('/admin/signin') 
     return $q.reject(response) 

    return (httpPromise) -> 
    return httpPromise.then(success, error) 
]).config(["$httpProvider", ($httpProvider) -> 
    $httpProvider.responseInterceptors.push("httpErrorInterceptorModule") 
]) 

errore è: Error: [$injector:unpr] Unknown provider: $$cookieReaderProvider <- $$cookieReader <- $cookies <- authService

cosa ho fatto di sbagliato? Grazie in anticipo. La versione di AngularJS è 1.2.25. Grazie in anticipo.

risposta

0

Questo perché quando si inizializza il modulo app.services, si dimentica di immettere ngCookies. Si include solo ngCookies in app, che è un modulo diverso.

una soluzione rapida qui sta cambiando la vostra definizione del modulo per

versione
angular.module('app.services', ['ngCookies']).factory('authService', ... 
+0

non funziona ... – malcoauri

+0

@malcoauri stesso errore? – Rebornix

34

angolare cookie.js devono avere la stessa versione che angular.js

"//code.angularjs.org/XYZ /angular-cookies.js " dove XYZ è la versione di AngularJS in esecuzione.

4

Se si utilizza angularJs versione 1.3, utilizzare angular-cookies 1.3.17!

Nel mio progetto ho lo stesso problema! Quindi ho fatto un downgrade!

Problemi correlati