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

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.

JS:

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

HTML:

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

Working Demo: https://jsfiddle.net/7MhLd/2659/

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

.pushed{color:red;}

In Controller

`$scope.Team=function(index,text,line){
  var obj={};
  obj = line;
  $scope.linesTwos.push(obj)
  line.pushed = true;
}`

`scope.Team2 = function(index,text2,line){
  $scope.linesTwos.splice(index,1)
  line.pushed = false;
}
`

its because angular two way binding