Answer the question
In order to leave comments, you need to log in
How to run the toggleClass method using Angular js if the string has a class?
My table:
<table>
<tr class="imp" toggle-class="active">
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="imp" toggle-class="active">
<td></td>
<td></td>
<td></td>
</tr>
</table>
angular.module("app")
.directive('toggleClass', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
element.toggleClass(attrs.toggleClass);
});
}
};
});
.active {background: blue;}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question