2017-04-21 56 views
0

我在這裏得到藥品每個迴路不打GET API

$scope.initStarttoGetDrugs = function() { 
      $http({ 
      url: '/MedicineParserApp/getmedicinefromdb', 
     method: "GET", 
      }).success(function(response){ 
      $rootScope.MedicinneName = response; 
      var medlength = response.length; 
      response.forEach(function(listItem, index){ 
     $scope.keyup(listItem) // here i want to hit the api 
      }); 
     }); 
      }; 
      $scope.initStarttoGetDrugs(); 

這裏控制檯它會網址的名單,但不打API,而不是讓響應

$scope.keyup = function (data) { 
    $http({ 
    url: 'https://www.example.com/medicineinfo/search?q='+data, 
    method: "GET", 
     }).success(function(response){ 
      console.log(response) 
     $scope.results = response.data; 
     $rootScope.vars = $scope.results 
     console.log($rootScope.vars); 
     for(var i = 0; i <= 3; i++) { 
      $scope.onclickfetchinfo($scope.results[i].slug, $scope.results[i].id) 
     } 
      }); 
     }; 

請讓我知道爲什麼這是happing和什麼是解決方案

編輯:使用settimeout,但仍然不工作;

回答