我有数据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;
});
错误:departures[i].flight.airport.origin.position is undefined
答案 0 :(得分:0)
小心你要找的东西。我看到了那条线
params: [:query, :type, :sort] # -> pass each into the link like "key: value"
你说它给departures[i].flight.airport.origin.position
应该是
undefined
您已将dailyData[i].flight.airport.origin.position
数组存储在data
答案 1 :(得分:0)
您收到错误departures[i].flight.airport.origin.position is undefined
,因为它实际上是未定义的。如果您查看JSON数据的结构,您会发现:
departures:{item:{},page:{},timestamp:value,data:[]}
所以你必须改变你的电话:
departures.data[i].flight.airport.origin.destination.position