Currently I am trying to make my mobile app to be like, a default gray color(active) for my OFF button when i go in my app. And a default green color(unactive) for the ON button. After ON button is being click, the ON button will change to gray(active) while the OFF button change to red(unactive). When I click OFF button, the button will change back to gray(active).
I am showing what a rough idea of what i want to implement but the button turn gray and not active when clicked. Anyone know how to code it with my flag remain?
controller.js
.controller('singleProjectorRoomCtrl', ['$scope', '$stateParams', function($scope, $stateParams) {
$scope.buttonState = false;
function toggleButtonState ()
{
if ($scope.buttonState == false)
{
$scope.buttonState = true;
}
else
{
$scope.buttonState = false;
}
};
$scope.goBack = function() {
window.history.back();
}
}])
html
<ion-view title="Single Projector Room" id="page9">
<ion-nav-buttons side="left">
<button class="button back-button buttons button-clear header-item" ng-click="goBack()">
<i class="icon ion-ios-arrow-back"> Back</i>
</button>
</ion-nav-buttons>
<ion-content padding="true" style="background: url(img/EDD79InSMCeYeMOSchjm_remote.jpg) no-repeat center;background-size:cover;" class="has-header">
<div class="row">
<div class="col"><br><br><br><br></div>
</div>
<div class="row">
<div class="col col-offset-5 col-30 text-center"><h4 style="color: #FFFFFF;">Single Projector Control</h4></div>
<div class="col col-30 text-center"><h4 style="color: #FFFFFF;">Screen Control</h4></div>
</div>
<div class="row">
<div class="col col-offset-5 col-30 text-center"><button class="button button-balanced button-large icon-right ion-power" ng-class="{buttonActive: buttonState == true}" ng-click="toggleButtonState = !buttonState"">On</button></div>
<div class="col col-30 text-center"><button class="button button-dark button-large icon-right ion-arrow-up-c">Up</button></div>
</div>
<div class="row">
<div class="col col-offset-5 col-30 text-center"><button class="button button-assertive button-large icon-right ion-android-cancel" ng-class="{buttonActive: buttonState == true}" ng-click="toggleButtonState = !buttonState">Off</button></div>
<div class="col col-30 text-center"><button class="button button-dark button-large icon-right ion-arrow-down-c">Down</button></div>
</div>
<div class="row">
<div class="col"><br><br></div>
</div>
<div class="row">
<div class="col col-offset-5 col-30 text-center"><h4 style="color: #FFFFFF;">Mic Control</h4></div>
</div>
<div class="row">
<div class="col col-offset-5 col-30 text-center"><button class="button button-balanced button-large icon-right ion-power">On</button></div>
</div>
<div class="row">
<div class="col col-offset-5 col-30 text-center"><button class="button button-assertive button-large icon-right ion-android-cancel">Off</button></div>
</div>
</div>
</ion-content>
</ion-view>
CSS
.myButtonClass {
background: gray;
}
.myButtonClass .buttonActive {
background: red !important;
}