2017-07-01 9 views
0

私はデータjsonスケジュールフライトを持っていますが、jsonはすべての情報を表示していません。それはちょうどいくつかのデータを返すだけで、すべてのデータはnullが既に存在することを示しています。 nullがあれば私のデータをチェックしたい、私は同じ質問を投稿するが、jqueryについては違う。

のショートコード:

nameApp.controller('bgwCtrl', function($scope, $http,$interval,labeltext,$timeout,$ionicLoading, $ionicPopup,arrivecss) { 

    $scope.loading = true; 
    // Setup the loader 
    $ionicLoading.show({ 
    content: 'Loading', 
    animation: 'fade-in', 
    showBackdrop: true, 
    maxWidth: 200, 
    showDelay: 0 
    }); 

    $scope.reload = function() { 

    $http.get("v1/airport.json?code=bgw") 
    .then(function(response) { 

    $timeout(function() { 
    $ionicLoading.hide(); 
    $scope.labeltext=labeltext; 
    $scope.check=arrivecss; 
    $scope.time= response.data.result.response.airport.pluginData.schedule.arrivals.timestamp; 

     var dailyData = response.data.result.response.airport.pluginData.schedule.arrivals.data; 
     console.log(response.data.result.response.airport.pluginData.schedule.arrivals.data); 

      $scope.dailyForecast = [null]; 

      for(var i=0; i<25; i++) 
      { 
       $scope.dailyForecast[i] = {callsin: dailyData[i].flight.identification.id, 
              callsign: dailyData[i].flight.identification.number.default, 
              statu: dailyData[i].flight.status.generic.status.text, 
              airline: dailyData[i].flight.airline.code.iata, 
              from: dailyData[i].flight.airport.origin.position.region.city, 
              timear: dailyData[i].flight.time.scheduled.arrival, 
              generic: dailyData[i].flight.status.text, 
              ident: dailyData[i].flight.identification.number.default, 
              timearrvie: dailyData[i].flight.time.estimated.arrival, 
              timearr: dailyData[i].flight.status.generic.eventTime.local, 
              model: dailyData[i].flight.aircraft.model.code, 
              icon: dailyData[i].flight.status.icon, 
              winir: dailyData[i].flight.airline.name, 




              }; 


      } 

      console.log(response) 
    }, 2000); 
      return response; 

    }); 
///response end/// 
    function switchEstimated(){ 
    $scope.show=!$scope.show; 
    } 

    $interval(switchEstimated,3000); 
    $timeout(function(){ 
     $scope.reload(); 
    },30000) 

    }; 
    ///reload end/// 
    $scope.reload(); 
     $scope.loading = false; 

}); 

my data json

エラー:departures[i].flight.airport.origin.position is undefined

答えて

0

は、あなたが探しているものに注意してください。私はあなたがdailyData

+0

をまだ同じ問題 –

0

あなたが実際にその未定義のため、エラーdepartures[i].flight.airport.origin.position is undefinedを取得しているにdata配列を格納しているとして、あなたはそれを与えることを言うライン

departures[i].flight.airport.origin.position 

undefined

dailyData[i].flight.airport.origin.position 

でなければならないことがわかり。あなたはJSONデータの構造を見れば、あなたは見つける:

departures:{item:{},page:{},timestamp:value,data:[]} 

をですから、次のようにあなたの呼び出しを変更する必要があります。

departures.data[i].flight.airport.origin.destination.position 
+0

まだ同じ問題 –

関連する問題