2015-08-22 80 views
0

我得到一個錯誤TypeError:無法讀取undefined.i的屬性'get'嘗試了很多方法但無法解決。Angularjs錯誤問題

mycode的是login.controller.js

(function() { 
    'use strict'; 

    angular 
     .module('app') 
     .controller('LoginController', LoginController); 

    LoginController.$inject = ['$location', 'AuthenticationService', 'FlashService']; 
    function LoginController($location, AuthenticationService, FlashService) { 
     var vm = this; 

     vm.login = login; 

     (function initController() { 
      // reset login status 
      AuthenticationService.ClearCredentials(); 
     })(); 

     function login() { 
    var usename=vm.username; 
    var password=vm.password; 

      vm.dataLoading = true; 

     $http.get('http://localhost:8080/ProjectManagement/REST/Login/Check?usename='+usename+'&password='+password+'').success(function(data, status, headers, config,response){ 

       if (data=="0") 
        { 

        } 
       else 
        { 


        } 


     }).error(function(data, status, headers, config,response) { 


     }); 

     }; 
    } 

})(); 

回答

1

你錯過添加$http依賴你內心的控制器,確保所有的依賴使用它之前被注入。

代碼

LoginController.$inject = ['$location', 'AuthenticationService', 'FlashService', '$http']; 
function LoginController($location, AuthenticationService, FlashService, $http) { 
+0

是代碼工作感謝ü –

+0

@PanduKoturu所接受的答案then..Thanks :) –