html - Change class in angularjs through controller -
please me change class of input[type=button] dynamically using angularjs , controller.
app.controller('anodekeypadcntrl',function($scope){ $scope.clicktwentyfour = function(event){ in function need highlight button (adding .active class it) }; });
<div class="keypadcontainer" ng-controller="anodekeypadcntrl child"> ------ <input type="button" value="24" id="twentyfour" class="twentyfour anodekeypadbutton" ng-click="clicktwentyfour($event)" /> ------------- </div>
you can use ngclass this. in markup like:
<input type="button" value="24" id="twentyfour" class="twentyfour anodekeypadbutton" ng-click="clicktwentyfour($event)" ng-class="mydynamicclass" />
this way can set mydynamicclass
either single string containing css class or array of strings directly controller
// controller code $scope.mydynamicclass = 'some-css-class';
this appended html. if @ ngclass docs see can attach functions return class, or write classes directly in html conditions attached.
Comments
Post a Comment