当我没有任何过滤器地点击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);
};
如何更新数组中的索引?或者如何删除右侧的项?