Trying to modify a boolean value when a user clicks on a JSON-populated table row. Here's an example of the setup...
$scope.prices = {
"Prices": [
{
"Code": "edl",
"Selected": false
},
{
"Code": "ead",
"Selected": false
}
]
}
This data is then connected to a table...
<table>
<tr ng-click="change(item.code)" ng-repeat="item in prices">
<td>{{prices.Code}}</td>
</tr>
</table>
Once a user clicks a row, the change function is triggered to toggle the selected value between true and false.
$scope.change = function (itemCode) {
//update the clicked code selcted value to True/False
// check the current value and switch
// Apologies for the confusion!
if(!$scope.prices.code.selected){
$scope.prices.code.selected = true
} else {
$scope.prices.code.selected = false
}
};
Seeking guidance on how to make this work within the change function. Any other approaches would be appreciated! Thank you