I am trying to update a Javascript object value so that I can push it into an new array for filtering, but I then need to reset the object's property value back to its original value for when the user removes the filter (the user can toggle it on and off). I have tried everything I have seen here on stackoverflow and nothing has seemed to work. I have tried:
if (ctrl.dataArray.indexOf(row) === -1) { var rowCopy = JSON.parse(JSON.stringify(row)); row.$$treeLevel = 0; ctrl.dataArray.push(row); row.$$treeLevel = rowCopy.$$treeLevel; }
I've also tried:
if (ctrl.dataArray.indexOf(row) === -1) { var rowCopy = angular.copy(row); row.$$treeLevel = 0; ctrl.dataArray.push(row); row.$$treeLevel = rowCopy.$$treeLevel; }
I'm essentially trying to update grid rows to show grids matching specific criteria, then set the grid back to it original state after the filter. I know the dataArray is getting updated with the "originalCopy" value after I am pushing into the array.But how can I keep this from happening?
I have to push the original row so the user can update it and then reset the filter and keep the updated grid cell value for saving.
How can I make my above code work?
visible
boolean on each row object, setting it to false if the row doesn't pass the filter, then loop through your rows and draw only the ones wherevisible === true
classList.toggle('myEffectOrLook')