【发布时间】:2016-01-21 11:30:37
【问题描述】:
我用 AngularJS 做表。我使用了orderBy 过滤器。之后我的删除功能开始删除另一行,除了我点击删除。
这里是过滤器:
<tr class = "table-row isActive-{{task.active}} rowNumber-{{$index + 1}}" ng-repeat = "task in tasks | filter:search:strict | orderBy: '-priority':true">
<td>
<span class="delete-link">
<input type="button" data-ng-click="removeRow($index)"/>
</span>
</td>
</tr>
和删除功能:
$scope.removeRow = function (productIndex) {
$scope.tasks.splice(productIndex, 1);
productIndex=0
};
我错过了什么?
【问题讨论】:
-
你必须在
removeRow函数中使用相同的顺序。 ng-repeat 中应用的过滤器排序不会对数组本身进行排序。