Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a table which I can sort by columns by using the orderBy filter in an ng-repeat row. I have a context menu that can make updates to that item up updates the row:

JavaScript
['Run Api', function ($itemScope) {
   var item = {};
   angular.copy($itemScope.item, item); //get the item from the repeat row
   item.ApiDiff = "spinner"; //change the current image to a spinner
   angular.copy(item, $scope.Items[$itemScope.$index]); //copy the item back to the array
   //Do some other stuff and get the new value for ApiDiff
}]


(I have a function that returns a green up arrow for positive numbers, a red down arrow for negative and a spinner.gif for the word "spinner". This is an easy way of setting the image to a spinner while we wait for the updated result)

The issue I have is that $itemScope.$index is the index of the item in the ordered array whereas $scope.Items is the un-ordered array. With sorting on, I get a miss match.

How do I update the original item in the array?

Thanks ^_^
Andy
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900