嵌套的ng-repeat $ first和$ last?

时间:2014-07-17 09:58:20

标签: javascript jquery angularjs

我有以下表格,

<tbody ng-repeat="attGroup in attributesGroups">
    <tr>
        <td class="vcenter text-right">
            &nbsp;&nbsp;<a href="javascript:" ng-click="!$last && updateGroupOrder(attGroup.id,'down')" title="move down"><i class="entypo-down-open-big"></i></a>
            &nbsp;&nbsp;<a href="javascript:" ng-click="!$first && updateGroupOrder(attGroup.id,'up')" title="move up"><i class="entypo-up-open-big"></i></a>                
        </td>
    </tr>
    <tr ng-repeat="att in attGroup.attributes">            
        <td class="vcenter text-right">
            &nbsp;&nbsp;<a href="javascript:" ng-click="!$last && updateAttributeOrder(att.id,'down')" title="move down"><i class="entypo-down-open-big"></i></a>
            &nbsp;&nbsp;<a href="javascript:" ng-click="!$first && updateAttributeOrder(att.id,'up')" title="move up"><i class="entypo-up-open-big"></i></a>

        </td>
    </tr>

你看我在attributesGroups ng-repeat和attributesGroups.attributes ng-repeat中都使用$ last / $ first。现在我的问题是第二个$ last和$ first属于attributesGroups或attributesGroups.attributes?

1 个答案:

答案 0 :(得分:2)

$first/$last取决于调用它的上下文。

<tbody ng-repeat="attGroup in XXX">
    <tr>
        <!--- HERE $first/$last belongs to XXX --->
    </tr>
    <tr ng-repeat="att in YYY">            
        <!--- HERE $first/$last belongs to YYY --->
    </tr>
</tbody>