Deadpool Deadpool -4 years ago 308
AngularJS Question

Adding class to element using Angular JS

I know how to add a class on click of a button in 'jQuery'


I want to achieve same thing by angular js. I have a controller - myController1. Can someone help me do it eazily?

Answer Source

AngularJS has some methods called JQlite so we can use it. see link

Select the element in DOM is

angular.element( document.querySelector( '#div1' ) );

add the class like .addClass('alpha');

So finally

var myEl = angular.element( document.querySelector( '#div1' ) );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download