Aditya Ponkshe
Aditya Ponkshe

Reputation: 3890

Change class of an element using AngularJS

In JavaScript one can change class of an element like this

document.getElementById("MyElement").className = "MyClass";

What is the alternative for doing something similar in AngularJS function? I am getting an element by using

var myElement = angular.element( document.querySelector( '#MyElement' ) );

now is there any way to change class of var myElement? or is it possible to do something similar to myElement.style ?

Upvotes: 0

Views: 251

Answers (1)

michael
michael

Reputation: 16341

Angular provides a jqLite implementation of jQuery. There are also funcitons available like

  • addClass,
  • removeClass
  • toggleClass.

Full spec: http://docs.angularjs.org/api/angular.element

Upvotes: 2

Related Questions