[英]angularjs filter null values in json array
我的Json数组如下
[["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]]
我正在使用以下Angular 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>
Angular 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]
,因为它具有空值最后。
我得到的输出是这个
如果要插入json对象的值不为null,请检入后端函数;如果条件为true,则将其插入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.