I have the below controller function that returns me a Boolean value.
Current HTML:
<a href="#" ng-click="collapseNavbar(true)" ng-model="collNavbar">
<i class="fa fa-arrow-right"></i>
</a>
layoutController:
App.controller('layoutController', ['$scope', function($scope) {
$scope.collapseNavbar = function(val) {
return $scope.value = !val;
}
}])
Based on that value I need to assign the <body> tag a class like yes or no.
Earlier I was using something like this to do it.
HTML :
<div class="toggle-sidebar navbar-nav">
<ul class="nav navbar-nav">
<li>
<a href="#" ng-click="isActive = !isActive" ng-model="collNavbar">
<i class="fa fa-arrow-right"></i>
</a>
</li>
</ul>
</div>
HTML2
<body ng-class="{'yes': isActive, 'no': !isActive}" ng-controller="layoutController">
But I don't want my code to be in the HTML file. Instead I created a controller for it named layoutController.js and above is the code used in it.
I'm able to pass the Boolean as a class to the body tag on pageload.
But I don't know how to pass it on a click of the a tag where as I've passed the function using ng-click.
Any suggestions like how can I do it will be very helpful for me in the learning it.
Thanks in advance.
$scope.valuewill always be false in your code.