【发布时间】:2014-07-11 15:42:33
【问题描述】:
当我在没有任何过滤器的情况下单击 tr 时,我的函数 array.splice() 有效。数组中的索引顺序正确,因此 array.splice() 有效。
启用过滤器时,数组中的索引不会更新,并且仍然保持相同的顺序。所以array.splice() 删除了错误的项目。
<span ng-click="orderP0 = 'statut_name'; reversePO=!reversePO">order</span>
<tr ng-repeat="project in projects | orderBy : orderPO : reverse track by $index" ng-click="remove($event,$index,projects)">
<span class="label" ng-bind="project.statut_name"></span>
</tr>
$scope.remove = function($event,index,array){
array.splice(index,1);
};
如何更新数组中的索引?或者如何删除正确的项目?
【问题讨论】:
-
你不能把项目传递给函数吗?即 ng-click="remove(project)"
标签: javascript arrays angularjs filter angularjs-ng-repeat