2017-10-04 2 views
3

버튼을 클릭 할 때 변환 함수가 호출되는 평균 스택 응용 프로그램이 있습니다. 버튼을 클릭하면,이 기능을 입력하지만, 다음 오류를 던지는 http.get 부분 실행할 수 없습니다 : 각도 js - TypeError : 정의되지 않은 'get'속성을 읽을 수 없습니다.

TypeError: Cannot read property 'get' of undefined

아래는 해당 페이지 내 각 코드입니다.

(function() { 
    var app = angular.module('dashboard', []); 
    app.config(['$stateProvider', function($stateProvider) { 
     $stateProvider.state('secured.dashboard', { 
      url: '/dashboard', 
      controller: 'searchController', 
      templateUrl: '/views/dashboard.html' 
     }); 
    }]); 

    app.controller('searchController', ['$scope', 'AuthService', '$state', '$http', function($scope, AuthService, user, $state, $http) { 
     console.log($scope.user) 
     // AuthService.setUser(user); 
     console.log("In search controller"); 
     $scope.logout = function() { 
      AuthService.logout().then(function() { 
       $scope.user = null; 
       $state.go('unsecured'); 
      }) 
     } 

     $scope.data = {}; 

     $scope.translate = function() { 
      console.log("Entered") 
      console.log($scope.item); 
      $scope.show_results = true; 

      $http.get('/mosesTranslateSmall', { params: { name: $scope.item }, timeout: 600000 }). 
      then(function(response) { 
       console.log(response.data); 
       $scope.data.moses_less = response.data; 

      }); 

저는 컨트롤러에서 http를 인수로 전달하는 것과 관련된 조언을 보았지만 그렇게하고 있는데도 여전히 오류가 발생합니다. 의존성의

답변

1

주문이 잘못,

app.controller('searchController', ['$scope', 'AuthService', '$state', '$http', function($scope, AuthService, $state, $http) { 
+0

PARAMS 감사의 두 번째 세트에서 user를 제거합니다. 컨트롤러와 함수의 논증에서 인수의 순서가 같아야 하는가? – Tarun

+1

네, 동일해야합니다. – Sajeetharan

+0

예, 처음에는 특정 시간 후에 만 ​​표시 할 수 있다는 것을 보여주었습니다. 나는 그것을 지금했다. 감사 – Tarun

관련 문제