I want to add an active class on click in a list, i tried the following code, but it adds the active class on all my items :/ :
HTML :
I'm well late to the party, but this is the most reusable pattern, and it will save you re-writing the same function every time.
HTML:
JS:
$scope.list = [{}, {}];
$scope.setActive = function(item, list){
list.some(function(item){
if(item.active){
return item.active = false;
}
});
item.active = true;
};