【发布时间】:2014-10-11 06:10:06
【问题描述】:
我正在使用 Angular 构建一个来自 JSON API 调用的数据表。我不得不使用嵌套的 ngRepeat,但是我看到奇怪的结果,当行有几个空字符串时,整个表行都丢失了。
我可以用下面的 plunk 重现。 http://plnkr.co/edit/VCzzzPzfgJ95HmC2f83P?p=preview
<script>
function MyController($scope){
$scope.test = {"rows":[
["one","two","three"],
["one","two","three"],
["one","","three"],
["one","",""],
["","two",""],
["","","three"],
["one","two","three"],
["one","two","three"],
]};};
</script>
<div ng-app ng-controller="MyController">
<table>
<tr ng-repeat="(key,ary) in test.rows">
<td>{{key}}</td>
<td ng-repeat="value in ary">{{value}}</td>
</tr>
</table>
</div>
请注意,当数组有两个空字符串时,嵌套的 ngRepeat 似乎会失败。
我要疯了吗?对此有解释吗?
【问题讨论】:
标签: angularjs angularjs-directive angularjs-ng-repeat