angularjs - Is watching variables in a directive the only way to trigger it at right time? -


You may have seen that pattern in the most common directions:

  Return {restrict: e ', scope: {val:' = '}, link: function ($ scope) {$ radius $ Watch ('val', function () {// All codes here ...}); }}; I was just fed up with that pattern, and was looking for some more beautiful things, as it would be a bit expensive to see the variable in every directive ... 

The purpose of that question is to get the Directive Link Function Code executed at the right time? In other words, when the directive variables are ready.

Anyone with better solutions

If you listen for a special event If you want, you can use $ broadcast to broadcast a specific event and then listen for it at $.


Comments