【问题标题】:angularJS add table row (TR) inside an ng-repeat -angularJS 在 ng-repeat 中添加表格行(TR)-
【发布时间】:2023-04-04 01:20:02
【问题描述】:

EDIT 这是一个类似(或重复)的 Angular.js ng-repeat across multiple elements

-

我有一个表,其行是通过 ng-repeat 生成的:

<tr ng-repeat="(key, value) in rows"> 
    <td>{{a}}</td>
    <td>{{b}}</td>
</tr>

出于各种原因,我真的更喜欢将它保留在

标记中,而不是几个内联块中。

如何在每行下方添加另一行,例如伪代码

[ somehow-repeat ng-repeat="(key, value) in rows"]
    <tr class="1"> 
        <td>{{a}}</td>
        <td>{{b}}</td>
    </tr>

    <tr class="1"> 
        <td colspan="2">
    </tr>
[ /somehow-repeat ]

据我所知(值得检查),我无法将 TR 包装在另一个元素中。只是检查一下 :( 如果我“不知何故重复”元素是或

所以 - 尽管在 ng-repeat 中,有没有办法添加新行?

【问题讨论】:

    标签: angularjs


    【解决方案1】:

    您可以使用重复开始和重复结束:

    <tr class="1" ng-repeat-start="(key, value) in rows"> 
        <td>{{a}}</td>
        <td>{{b}}</td>
    </tr>
    
    <tr class="1" ng-repeat-end> 
        <td colspan="2">
    </tr>
    

    【讨论】:

      猜你喜欢
      • 2015-08-06
      • 2013-11-23
      • 1970-01-01
      • 2013-01-10
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      相关资源
      最近更新 更多