我有多种收入来源,我想将其显示在表格中。我将导入两个以上的值,并且我希望能够将它们并排放置以便于比较。但是,下面的代码肯定不起作用。 https://plnkr.co/edit/Vkcc9YUnEIc3PuuS8Yv3?p=preview
<table>
<tr>
<td ng-repeat="type in informationNames">{{type}}>
</td>
<td ng-repeat="type in informationValues1">{{type}}>
</td>
<td ng-repeat="type in informationNameValues2">{{type}}>
</td>
</tr>
</table>
我发现了这个,但这并不真正适用,因为它只有 1 个数组,而我将导入 2 个以上的数组。 Angular ng-repeat in table
最佳答案
您可以将每个重复放在不同的行中,这样您的代码将如下所示:
<table>
<tr>
<td ng-repeat="type in informationNames">{{type}}
</td>
</tr>
<tr>
<td ng-repeat="type in informationValues1">{{type}}
</td>
</tr>
<tr>
<td ng-repeat="type in informationNameValues2">{{type}}
</td>
</tr>
</table>
这样它们就都被垂直列出了
如果您希望它们水平排列并且您知道所有列表的长度相同,您可以这样做:
`
<table>
<tr ng-repeat="name in informationNames">
<td>{{name}}
</td>
<td>
{{informationValues1[$index]}}
</td>
<td>
{{informationNameValues2[$index]}}
</td>
</tr>
</table>
关于javascript - 表中的 Angular 重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39214912/