如何创建一个角度NG重复内一个新行? [英] How do I create a new row inside an angular ng-repeat?

查看:116
本文介绍了如何创建一个角度NG重复内一个新行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 NG-重复创建行,我要定期插入新行。但对于创建这个逻辑是行内并最终搞乱了嵌套,例如:

I have an ng-repeat creating rows, and I want to insert a new row periodically. But the logic for creating this is inside the row and ends up messing up the nesting, for example

  <tr ng-repeat='item in items'>

       <!-- this doesn't work well -->
       <tr ng-if='items[$index].day != items[$index-1].day'>
       <td colspan=2>
       NEW DAY
       </td>
       </tr>

       <td>{{item.name}}</td>
       <td>{{item.day}}</td>

    </tr>

我想要的数据行,只要一天之中的变化天分频器的行。

I want the "day divider" rows amongst the data rows whenever the day changes.

推荐答案

您可以使用NG-重复启动和NG-重复高端如下:

You can use ng-repeat-start and ng-repeat-end as follow:

<tr ng-repeat-start="item in items">
       <td>{{item.name}}</td>
       <td>{{item.day}}</td>
    </tr>
    <tr ng-repeat-end>
       <td>Expand/collapse content</td>
    </tr> 

演示

这篇关于如何创建一个角度NG重复内一个新行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆