Angularjs 双重循环获取父级下标$index

 

<table class="table table-bordered">
        <tr ng-repeat="info in ttzInfo" ng-cloak>
          <td class="col-xs-2 adjust-col-2 text-right title-desc" ng-bind="info.title"></td>
          <td class="col-xs-3 adjust-col-3 text-center" ng-repeat="key in ['ttz', 'yeb', 'bank']">
            <span ng-if="info[key]">
              <span ng-if="info[key].length" ng-bind="info[key]" ng-class="{'year-interest': $parent.$parent.$parent.$first}"></span>
              <span ng-if="!info[key].length" class="glyphicon glyphicon-ok"></span>
            </span>
            <span ng-if="!info[key]" class="glyphicon glyphicon-remove"></span>
          </td>
        </tr>
      </table>

 

 

直接获取父级下标,只有两个ng-repate写在一起的时候,使用 $parent.$index即可获取,若没多一级ng-if之类的判断条件,则接着在往上一级寻找即可。

其他ng-repate的函数都是同一个道理。

Angularjs在线教程:

http://each.sinaapp.com/angular/tutorial/ng-repeat.html

 

VariableTypeDetails
$indexnumberiterator offset of the repeated element (0..length-1)
$firstbooleantrue if the repeated element is first in the iterator.
$middlebooleantrue if the repeated element is between the first and last in the iterator.
$lastbooleantrue if the repeated element is last in the iterator.
$evenbooleantrue if the iterator position $index is even (otherwise false).
$oddbooleantrue if the iterator position $index is odd (otherwise false).
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值