1

I want to change my background-color to lightblue when the value of the checkbox is true, and change the background-color back to normal when the value is false.

<tr ng-repeat="item in rows | filter:search" ng-class="{'selected':$index == selectedRow}">

My Checkbox:

<td><input type="checkbox" ng-click="setClickedRow($index)"></td>

My Function:

$scope.selected = null;  
$scope.setClickedRow = function(index){  
    $scope.selectedRow = index;
}

1 Answer 1

2

Here you have a plunker with your example: http://plnkr.co/edit/CHB65fe6Bsd3PdjWjoT4?p=preview

This is the table:

<table style="width:100%">
<tr ng-repeat="item in rows | filter:search" ng-class="{'selected': item.selected}">
  <td>
    <input type="checkbox" ng-model= "item.selected" ng-click="setClickedRow($index)">
  </td>
</tr>
</table>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.