I'm trying splice items from an array but it removes the wrong item each time. I believe it is becuase I filter the array array using orderBy, so the array on the DOM is different from the array in the controller. My question now is how do I correctly splice the right item from the array even after filtering, and also is there any way I can use the orderBy filter in by controller?
Heres my controller
office.controller('notificationCtrl',['$scope',$http',function($scope,$http){
$scope.latest = [
{
id:1,
date : "2017-01-11T19:33:17.307452",
arrived: false,
location : "europe"
},
{
id: 2,
date: "2017-01-11T20:19:47.745673",
arrived:false,
location : "africa"
}
]
$scope.accept = function(array,index){
array.splice(index,1)
}
}]
Source.html
<div ng-repeat="recent in latest | orderBy : recent.date : true">
<button ng-click="accept(latest,$index)">Accept</button>
</div>
EDIT I've added example data as requested, in the data above if I try to splice the second item, it spices the first instead.