Remove item from list after filtering

回眸只為那壹抹淺笑 提交于 2019-12-04 00:46:32

As mentioned by @pkozlowski.opensource, you can't depend on $index to identify an item in an array in this way. I would make the following changes:

HTML:

<td><a ng-click="deleteWish(coupon)"><i class="icon-trash"></i></a></td>

JS:

$scope.deleteWish = function (coupon) {
    var index = $scope.coupons.indexOf(coupon);
    if (index != -1) {
        $scope.coupons.splice(index, 1);
    }
}

Here is a working Plunker: http://plnkr.co/edit/b0b2cYGsM5wtw8hIrQB5?p=preview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!