javascript - Angular directive run if scope values update -


I wrote a tutorial that sets the basic elements of the original element equal to the height of the child element of the highest element. Here is the directive code:

  app.directive ('equalHeightChildren', function () {return function (scope, element, ethers) {var $ tallest = element; $ .each (element.children } (), Function (index, child) {if ($ (child). Outer ()> $ tallest.outerHeight ()) {$ tallest = $ (child);}}); Element.children () External heights ($ highest. Roughheit (+ + 'px');}});  

This code runs as a page load and adjusts the heights properly. However, I have some scope variables in my app, which can change the height of these hair elements (for example, the check box shows a new look in one of the elements of the child, increases its height). I was hoping that instructions will be issued due to changes in one of these changes, which would adjust the heights of hair elements again. However, it does not seem so.

Is there a way to run the scope when the scope variables change? Or am I thinking about it wrongly?

If you want to run it again, The other option is an event for a fire and this instruction handles it.

  app.directive ('equalHeightChildren', function () {return function (area, element, attrs) {var setTallest = function () {var $ tallest = element; $ .each (element .children (), function (index, child) {if ($ (child). OuterHeight ()> $ tallest.outerHeight ()) {$ tallest = $ (Child);}}) element.children () Outside Heights ($ tallest.outerHeight () + 'px')}} setTallest (); // To reset the height to use any of these, // $ radius. $ Watch ('myVar', Function () {setTallest ();}); // $ rootScope.on ('eventTrigger', Settlele);}});  

Comments