Angularjs - how to shuffle the class names using the scope function? -
i have 3 elements, shows conditional. on click of them using 'ng-class' showing or hiding element.
here html :
<div class="useroptions"> <div class="row designoption" ng-class="{'active':prodesign}"> <span ng-click="categories('prodesign')" class="icon icond">d</span> <span class="info infod">design</span> </div> <div class="row suplyoption" ng-class="{'active':supply}"> <span ng-click="categories('prosupply')" class="icon icons">s</span> <span class="info infos">supply</span> </div> <div class="row constoption" ng-class="{'active':construct}"> <span ng-click="categories('proconstruct')" class="icon iconc">c</span> <span class="info infoc">construction</span> </div> </div>
but using scope
function not able shuffle class name active
. here try:
$scope.prodesign = false; $scope.proconstruct = false; $scope.prosupply = false; $scope.categories = function (categ) { $scope.prodesign = false; //all false. $scope.proconstruct = false; $scope.prosupply = false; $scope[categ] = !$scope[categ]; //became true }
but not working. if so, correct way this?
Comments
Post a Comment