Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change class in angularjs through controller

Please help me to change the class of input[type=button] dynamically using angularjs and controller.

app.controller('anodekeypadcntrl',function($scope){
	
	
	$scope.clickTwentyFour = function(event){
	  In this function I need to highlight the button (adding the .active class to it)	
	};
	                            
});
<div class="keypadcontainer" ng-controller="anodekeypadcntrl as child">
  ------
  <input type="button" value="24" id="twentyFour" class="twentyfour anodeKeypadButton"
	ng-click="clickTwentyFour($event)" />
  -------------
</div>
like image 381
Anusha Sajeendran Avatar asked May 15 '15 06:05

Anusha Sajeendran


1 Answers

You can use ng-class to dynamically add class to your divor button or whatever

Here is a working plunker with your code

http://embed.plnkr.co/rzS8GV975BHRk83xhsPx/preview

Hope this helps

like image 114
Alhuck Avatar answered Nov 06 '22 07:11

Alhuck