2016-10-05 96 views
0

Click here to see error message

遇到錯誤$注射器:unpr未知提供商爲$餅乾

我加入了ngco​​okies模塊在我的app.js文件,然後使用當Cookie服務在我的控制器注入在我的控制器$ cookie的服務,但我不能創建一個cookie 拋出錯誤

app.js

​​ 個

controller.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); 
      }); 

請幫助解決售後服務這個錯誤

回答

0

您在這裏漏掉了一些注射:

app.js

angular.module('advogeApp', [ 
'ngResource', 
'ngCookies', 
'editorCtrl', 
'SigninCtrl', 
'SignupCtrl']).config(['$routeProvider','$httpProvider', '$cookies', function($routeProvider, $httpProvider, $cookies){ 
    $httpProvider.defaults.xsrfCookieName = 'csrftoken'; 
    $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; 
}]); 

EDIT(試試這個)

controller.js

var app = angular.module('advogeApp', ['ngCookies']); 

也許它是壓倒一切的模塊?

+0

可以ü告訴任何遺漏注射 – jayanthanantharapu

+0

看我的代碼和你之間的差異性,我剛纔說的:'「$ httpProvider」,「$ cookies'' –

+0

@stevee Pitis同樣的錯誤來了 – jayanthanantharapu

相關問題