AngularJS Toggle Buttons
by Anov Siradj
HTML
<button ng-click="toggle()" ng-class="{on:b.state}" ng-repeat="b in btns">{{b.label}}</button>
CSS
button.on {
background-color: lightgreen;
}
JavaScript
function ctrl($scope) {
$scope.btns = [{
label: "One",
state: false
}, {
label: "Two",
state: true
}, {
label: "Three",
state: false
}];
$scope.toggle = function () {
this.b.state = !this.b.state;
};
}