$scope.isVisible = false;
$scope.selectionCheck = function () {
if ($scope.printer1 != undefined) {
if ($scope.printer1.isSelected == true) {
return 'selected';
} else {
return 'normalclass';
}
}
// I wanted to remain selected
if ($scope.printer2 != undefined) {
if ($scope.printer2.isSelected == true) {
return 'selected';
} else {
return 'normalclass';
}
}
};
.normalclass {
background: lightgrey;
color: white;
}
<div ng-show="printer1Visible">
<button ng-class="{'selected': 'printer1.isSelected'}"
ngclick="tryit(printer1)" style="margin-bottom: 20px;" class="normalclass btn btn-success btn-lg">{{printer1.printerName}}{{selected1}}</button><br />
</div>
<div ng-show="printer2Visible">
<button style="margin-bottom: 20px;" ng-class="{'selected': 'printer2.isSelected'}" ng-click="tryit(printer2)" class=" normalclass btn btn-success btn-lg"> {{printer2.printerName}}{{selected2}}</button>
<br />
</div>