I have a HTML table row element (tr) with an ng-class associated to it. The 'active' class is a CSS style that highlights the table row. There is a condition (selRole==role) to indicate that the selected role must be highlighted.
#rolesTable tr.active td {
color: #ffffff;
background-color: #2a9fd6;
}
<tr ng-class="{'active':selRole==role}" ng-click="setCurrentRole(role)" ng-repeat="role in roles">
<td>{{ role.Name }}</td>
</tr>
$scope.setCurrentRole = function (role) {
$scope.selRole = role;
$scope.permissions = role.Permissions;
$scope.selPermission = null;
$scope.selRoleIndex = $scope.roles.indexOf(role);
}
Right now when I click on a row, it changes color to indicate I selected it.
The problem I have is that sometimes I need to refresh the list of roles in the table. The selRole property keeps it value but when I refresh the list I lose the highlight.
Even when I force the code to execute the function setCurrentRole, it does not automatically highlight. I explicitly need to click on it to highlight it.
I need for the selected role to remain highlighted, even when I refresh the list. I don't know how to do this in AngularJS.