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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -