I'm trying to change the selected row of an ng-table. Using this code I can select the first row of the ng-table however on the initial call the data-ng-class
does not seem to be triggering because the style is not being applied to the selected row. However on the second call to the function the style is applied.
This is our selection function:
function changeSelection(agreement) {
if (agreementNumberService.isSelectable === true) {
agreementVM.isSelectable = true;
if (agreement.$selected) {
agreement.$selected = !agreement.$selected;
} else {
agreement.$selected = true;
}
//agreement.$selected = !agreement.$selected;
if (agreementVM.selectedItem && agreementVM.selectedItem !== agreement) {
agreementVM.selectedItem.$selected = false;
}
agreementVM.selectedItem = agreement;
}
}
This is the table row:
<tr data-ng-repeat="agreement in $data" data-ng-click="vm.changeSelection(agreement, $event)"
data-ng-class="{'active': agreement.$selected}">
Do you have any idea why the style is not being applied on the first call to the function but is on subsequent calls? Thanks in advance.
The following change to the view fixed the problem. There was a problem with the previous expression.