user93 user93 - 2 months ago 7
AngularJS Question

how to trigger a function inside a directives controller when attribute to a directive changes

I am trying to call a function inside directives controller as soon as the value to directives attribute changes how do proceed with that thank in advance

Answer

In the controller you have the $attrs :)

$attrs.$observe("myAttr", function(newValue){
  console.log("the attribute my-attr changed to: ", newValue);
})

Comments