I am having a situation like in this post here only that I not only need to fetch the element, but change its e.g. name value.
I already found out that one could do it like that:
dataList.splice(index, 1);
dataList.splice(index, 0, newItem);
But there are several problems. I know the id but if I am manipulating the array from time to time I will loose track of the index <=> id correlation because with this method i will take out items, change them and push them as a "new" one, right? But that is kind of not really elegant and could cause problems I think.
Basically I just want to toggle a visible attribute which then should change in the array. Here is the array:
$scope.cLines = [{ id: 1, cColor: 'red', cName: 'Entryline right', visible: true }];
Of course there are usually more elements inside, but I left one for simplicity reasons.
The visible toggler should be working like that (naiv "pseudocode" which would be really awesome if it would work like that simple :) )
$scope.cLines[id === id].visible = !$scope.cLines[id === id].visible;
Second best thing would be if I could access the element directly with the filter, is that possible?
Thank you in advance.