Seeking assistance with an onClick event in Angular.js (ng-click) to toggle the color of a table row upon clicking.
Initial implementation is as follows:
<tr>
<td ng-class="{'setType': types.isTypeSet('TYPE') == true}" ng-click="types.setType('TYPE')">
<img class="typebox-img" src="">
<div class="typebox">TYPE</div>
</td>
</tr>
'Type' refers to the type of table row and 'types' corresponds to the angular controller.
Function types.setType(type):
...
this.types[type] = ! this.types[type];
...
Upon testing, the values are toggled from the second click onward, but not on the first. Implemented functionality using if-else statements, yet puzzled why it's failing to work correctly - seems like a basic task.
By default, this.types[type] is set to false.
If anyone can shed light on what might be causing this behavior, that would be much appreciated!