Is it possible to ‘watch’ attributes’ changes

Yes. You can use attr.$observe if you use interpolation at the attribute.

But if this is not an interpolated attribute and you expect it to be changed from somewhere else in the application (what is extremely not recommended, read Common Pitfalls), than you can $watch a function return:

scope.$watch(function() {
    return element.attr('class'); 
}, function(newValue){
    // do stuff with newValue
});

Anyway, its probably that the best approach for you would be change the code that changes the element class. Which moment does it get changed?

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)