0
的json數組如下angularjs過濾空值
[["2017-01-11",8327.8,8389.0,8322.25,8380.65,192285417.0,8938.68],["2017-01-10",8262.7,8293.8,8261.0,8288.6,147312927.0,6904.57],["2017-01-09",8259.35,8263.0,8227.75,8236.05,102211190.0,5197.62],["2017-01-06",8281.85,8306.85,8233.25,8243.8,143689850.0,7298.74],["2017-01-05",8226.65,8282.65,8223.7,8273.8,163957452.0,8180.68],["2017-01-04",8202.65,8218.5,8180.9,8190.5,136476345.0,6543.13],["2017-01-03",8196.05,8219.1,8148.6,8192.25,131186021.0,6053.67],["2017-01-02",8210.1,8212.0,8133.8,8179.5,null,null],["2016-12-30",8119.65,8197.0,8114.75,8185.8,131457250.0,5800.7],["2016-12-29",8030.6,8111.1,8020.8,8103.6,null,null]]
我使用下面的角度js腳本拉起記錄
<table border="1" cellpadding="5" cellspacing="0">
<thead>
<tr>
<th>Sno.</th>
<th ng-repeat="header in headers">{{ header }}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in data">
<td>{{$index+1}}</td>
<td ng-repeat="(key,info) in row">{{info}}</td>
</tr>
</tbody>
</table>
角JS代碼
$http.jsonp(url)
.success(function(data){
console.log(data);
$scope.headers=data.dataset.column_names;
$scope.description=data.dataset.description;
$scope.data=data.dataset.data;
});
問題是代碼中斷,它在數組中找到空值,例如整行["2017-01-02",8210.1,8212.0,8133.8,8179.5,null,null]
從表中遺漏,因爲它在最後具有空值。
我得到的輸出是 this
您正在使用哪個版本的Angular? – superUser
爲什麼不在「.success」事件處理函數中檢查null數據,然後再訪問它的字段? – vvtx