javascript - 表中的 Angular 重复

标签 javascript angularjs arrays

我有多种收入来源,我想将其显示在表格中。我将导入两个以上的值,并且我希望能够将它们并排放置以便于比较。但是,下面的代码肯定不起作用。 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/

相关文章:

javascript - 验证服务对象在 angularjs 中刷新时丢失页面

javascript - 在 Protractor 测试中获取和使用属性

arrays - 如何在 julia 中启动带有列表元素的列表?

python - reshape numpy为滞后值添加额外维度

arrays - 从像素阵列问题中获取 NSImage (Swift)

javascript - 通过 node.js 发送 android 推送通知

javascript - Angular 2 不渲染带有文件扩展名的依赖链接

javascript - Angular UI 网格 : Hover on expandable row

javascript - 如何防止停止滚动悬停 iFrame(完美滚动条)?

javascript - Socket.IO 与 Node.js 有何作用