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

标签 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?

最佳答案

$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>

关于javascript - 嵌套 ng-repeat $first 和 $last?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24800399/

相关文章:

javascript - 带嵌套 IF 语句的 FOR LOOP

javascript - 创建 dijit.tooltipdialog 时如何设置位置。

javascript - Bootstrap : How to display 2 tab-contents by clicking on a single tab?

javascript - 在 $scope.$watch 中调用一个函数

python - Django 测试、交易和 Angular Protractor

javascript - 您在任何时候可以拥有的 JavaScript 对象的数量是否有限制?

javascript - onsubmit 不显示按钮

jquery - 如何将 jQuery UI 日期选择器附加到动态插入的表单域?

html - 根据复选框更改文本区域的样式

javascript - 向 li-Element 添加类