Angular List color change based ng-click

I am using angularjs I have two list when I click first one I will push the value into another scope and bind the value to second list. Now my requirement is when first list values which are moved to second list, I need to change the color of moved values in list1
Here I attached my fiddle


You can use findIndex and ng-class together to check if the second list contains the same item as first. If present apply css class to the first list item.


   $scope.checkColor = function(text) {
       var index = $scope.linesTwos.findIndex(x => x.text === text);
       if (index > -1) return true;
       else return false;


<li ng-click="Team($index,line.text)" ng-class="{'change-color':checkColor(line.text)}">{{line.text}}</li>

Working Demo:

You can do something like this:

you have to achieve it using ng-class and create a dynamic class style for pushed data please check my working example fiddle
JS fiddle sample

in HTML nedd to do these changes

<li ng-click=”Team($index,line.text,line)” ng-class=”{‘pushed’:line.pushed}”>

<li ng-click="Team2($index,line.text,line)">

In css


In Controller

  var obj={};
  obj = line;
  line.pushed = true;

`scope.Team2 = function(index,text2,line){
  line.pushed = false;

its because angular two way binding