得到错误 $injector:unpr Unknown Provider for $cookies
我在我的 app.js 文件中添加了 ngcookies 模块,并在我的控制器中使用了 $cookie 服务,但是当我的控制器中注入 cookie 服务时,我无法创建 cookie 抛出错误
应用程序.js
angular.module('advogeApp', [
'ngResource',
'ngCookies',
'editorCtrl',
'SigninCtrl',
'SignupCtrl']).config(['$routeProvider', function($routeProvider, $httpProvider, $cookies){
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
}]);
控制器.js
var app = angular.module('advogeApp');
app.controller('SigninCtrl', ['$scope', '$http', '$cookies', '$location', function($scope, $http, $cookies, $location) {$scope.loginData = function () {
angular.element('#signin').modal("hide");
$http({
method : 'POST',
url : '/proxy/',
headers: {'Content-Type': 'application/json', 'endpoint' : '/login/'},
data : JSON.stringify({email : $scope.userEmail, password : $scope.userPwd}),
}).then(function(response){
$cookies.put('set-cookie', response.data.headers['set-cookie']);
if (response.data.body.info == "sucessfully logged in") {
$location.path('/dashboard');
} else {
$scope.logininfo = response.data.info;
console.log(response.data);
}
},function(response){
console.log(response);
});
请帮助解决这个错误