My main module definition:
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)
])
Also in index.html is <script src="/assets/angular-cookies/angular-cookies.js?body=1">
. I get the error in this module:
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")
])
Error is: Error: [$injector:unpr] Unknown provider: $$cookieReaderProvider <- $$cookieReader <- $cookies <- authService
What I do wrong? AngularJS version is 1.2.25.
angular-cookie.js version must have the same version that angular.js
"//code.angularjs.org/X.Y.Z/angular-cookies.js" where X.Y.Z is the AngularJS version you are running.
If you use angularJs version 1.3 use angular-cookies 1.3.17!
In my project i have the same problem! So i did a downgrade!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With