AngularJs Toggle Class using ng-class – It is very simple to toggle the class the class using ng-class in angularJs. Here in this tutorial we are going to explain how you can add the toggle class functionality using ng-class. You can use our online editor to edit and see the output of the example.
AngularJs Toggle Class using ng-class
You can add the toggle class functionality using the ng-class as below –
AngularJs Toggle Class using ng-class Example:
<div ng-app="myApp"> <div ng-controller="myController"> <div ng-class="{'class1':!blueBg, 'class2': blueBg}" class="amp-wp-inline-70b4dc64825cd6cedd611d137199d367">{{ blueBg }}</div> ToggleBg </div> </div> |
If you run the above example it will produce the output something like this-