javascript - Updating an object in array -


i trying update object in array two-way binded directive not working @ all.

i doing following update it:

   $filter('filter')         ($scope.offers, {id: offer_id})[0].status = "active"; 

i no console errors if console.log $scope.offers after filter code executed, status not updated.

what trying accomplish update object in $scope.offers array new value. every object in array has id attribute unique trying select by.

hope information sufficient. thanks!

here updating status of outcome of filter expression.

that means $filter('filter')($scope.offers, {id: offer_id}) returns array. , updating array, not actual array.

i believe, $scope.offers 2 way binded , not updating it.

i hope makes sense. , if can explain want. can put more light.

edit

so, think once new status value , id on need update. can iterate array using simple for loop , check id , if matches update status. this.

for(var i=0; i<array.length; i++) {     if (array[i].id === requiredid) {         array[i].status = newstatus;         break;     } } 

hope, helps.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -