I'm attempting to dynamically change the sp-right class to sp-left in Angular:
Html
<span class="sp-right">
<label>
Number:
</label>
</span>
Directive
app.directive("buttonThatTrigger", function () {
return {
restrict: 'C',//target all elements with class button-that-trigger
link: function (scope, element, attrs) {
element.click(function(){
$('.sp-right, .sp-left').toggleClass("sp-right sp-left");
});
}
};
});
Everything works perfectly, but when I navigate back to the page the changes revert back to the original class!
Any suggestions on how to fix this issue?