如何在指令属性更改时触发指令控制器内的函数

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

我正在尝试在指令属性的值发生变化时立即调用指令控制器内的函数如何进行提前谢谢

在控制器中你有 $attrs :)

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