【发布时间】:2017-05-29 10:48:59
【问题描述】:
我对 ng-repeat 指令的结构有点复杂,并且在循环遍历它时卡住了。我只是在数组中发布数据表示 JSON 格式
{"data":[
["sameer","1001",
[
{"button_icon":"fa fa-pencil",
"button_tt":"create invoice",
"button_color":"btn-success"
},
{"button_icon":"fa fa-pencil",
"button_tt":"create invoice",
"button_color":"btn-danger"
}
]
],
["jack","1002",
[
{"button_icon":"fa fa-pencil",
"button_tt":"create invoice",
"button_color":"btn-success"
},
{"button_icon":"fa fa-pencil",
"button_tt":"create invoice",
"button_color":"btn-danger"
}
]
]
}
它是一个数组(数组(数组())),最后一个内部数组是一个按钮,它将附加到每一行。我在附加那个按钮时被卡住了。我已经在使用嵌套的 ng-repeat 但对第三个感到困惑。
这是我的 html
<tbody>
<tr ng-repeat = "row in list.data">
<td ng-if = "(row.length - 1) != $index" class="text-center" ng-repeat = "val in row track by $index" ng-cloak>{{val}}</td>
<td ng-if = "(row.length - 1) == $index" class="text-center">
<div class="btn-group" ng-cloak>
<a ng-repeat = "btn in row" data-toggle="tooltip" title="{{btn.button_tt}}" class="btn btn-xs {{btn.button_color}}" data-original-title="Edit" ng-click="viewExpense(1)"><i class="{{btn.button_icon}}"></i></a>
</div>
</td>
</tr>
【问题讨论】:
-
你能用 plunker 提供这个正确的格式吗
-
请提供一个plunker。
标签: javascript angularjs angularjs-ng-repeat angular-ng-if