I have a group of boolean variable that toggles other variables to false if flagged as true.
Is there a clean pattern to this approach? Considering that the number of boolean variables might increase.
angular.module("app", [])
.controller("controller", function($scope) {
$scope.a = true;
$scope.b = false;
$scope.c = false;
$scope.toggleA = function() {
$scope.a = true;
$scope.b = false;
$scope.c = false;
}
$scope.toggleB = function() {
$scope.b = true;
$scope.a = false;
$scope.c = false;
}
$scope.toggleC = function() {
$scope.c = true;
$scope.b = false;
$scope.a = false;
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="controller">
<button ng-click="toggleA()">A is {{a}}</button>
<button ng-click="toggleB()">B is {{b}}</button>
<button ng-click="toggleC()">C is {{c}}</button>
</div>
angulartag too...as there might be something built in