I have created a service in angularjs which seems fine to me but when I inject $cookieStore into the service it gives me an uncaught error and I dont know why this is occurring.
Error:
angular.js:36Uncaught Error: [$injector:unpr] http://errors.angularjs.org/1.2.16/$injector/unpr?p0=%24%24cookieReaderProv…ieReader%20%3C-%20%24cookies%20%3C-%20%24cookieStore%20%3C-%20loginService
Service file:
myApp.factory('loginService', ['$q','$http','API_SERVER','$cookieStore',function ($q, $http, API_SERVER,$cookieStore) {
var login = function(username,passowrd){
// some code
},
var logout = function(username,passowrd){
//some code
}
return {
login: function (username, password) {
return login(username, password);
},
logout: function (username, token) {
return logout(username, token);
},
};
}]);
If I remove $cookieStore then it works properly. But including the code above throws the error. Also if I add $scope to service it throws an uncaught error.
app.js:
var myApp = angular.module('myApp', ['ngRoute',
'ui.bootstrap',
'ngCookies',
'ngResource',
'ngSanitize',
])
index.html
<script src='{% static "js/angular.min.js" %}'></script>
<script src='{% static "js/ui-bootstrap-tpls-0.11.2.min.js" %}'></script>
<script src='{% static "js/angular-route.min.js" %}'></script>
<script src='{% static "js/angular-animate.min.js" %}'></script>
<script src='{% static "js/angular-resource.min.js" %}'></script>
<script src='{% static "js/angular-cookies.min.js" %}'></script>
<script src='{% static "js/angular-sanitize.min.js" %}'></script>