我有一个包含许多对象的对象。 objects属性是一个用户名属性,包含一个对象,该对象的属性是组,值为true或false。
ReportModel.Taxonomy = {
Authenticated Users: Object
Test Group 1: " ✓ "
Test Group 2: " ✓ "
Test Group 3: " - "
Test Group 4: " - "
Test Group 5: " ✓ "
Test Group 6: " - "
Test Group 7: " - "
Test Group 8: " ✓ "
TestGroup: " - "
Test Users: Object
Test Group 1: " - "
Test Group 2: " - "
Test Group 3: " - "
Test Group 4: " ✓ "
Test Group 5: " - "
Test Group 6: " ✓ "
Test Group 7: " - "
Test Group 8: " - "
TestGroup: " - "
}
我一直在尝试使用ng-repeat创建一个表,其中每个行在标题之后提供用户名(第1列)和每个组的结果: < / p>
<table>
<tr class="reportHeader" >
<th>USERS</th>
<th ng-repeat="group in ReportModel.groups">{{group.name}}</th>
</tr>
<tr ng-repeat="user in ReportModel.taxonomy">
<td>{{user.name}}</td>
<td ng-repeat="user.userGroups"></td>
</tr>
</table>
根据Taxonomy对象的设置方式,我无法弄清楚如何使用ngRepeat。
答案 0 :(得分:1)
这是你正在尝试做的事情: How can I iterate over the keys, value in ng-repeat in angular
例如:
<table>
<tr ng-repeat="(key, user) in ReportModel.taxonomy">
<td>{{key}}</td>
<td ng-repeat="(key, group) in user"></td>
</tr>
</table>