javascript - Directive not able to access ng-repeated children until after a digest -


I am writing a guide on the UL elements, often with the children stamped using NG-repeat Are there. I need access to these children to make some copies, but in my postlink function, if I call iElement.children (), I will get an empty list! Even stranger is that if I use Dome property, i.e.lelegance [0]. Children, I get a real list. I can fix it by wrapping everything in $ timeout, but it creates a flicker because I manipulate some DOM in my code. I tried to use the scope. $ EvalAsync, but then the children are not there, as any ideas as what is happening before? I am most curious why DOM works children's property but jqLite Children () is not the method.

Perhaps what happens here that instructions are bound and fire before ng revision Finished eliminating elements on the scene

You can solve this with your $ 1 broadcast event from your controller and hold it inside the director with $ at the event listener.

  if ($ radius. $$ last === true) {$ radius. $ Broadcast ('NGRPAPT'); }  

and inside your directorate

  scope. $ ('NgRepeatFinished', function () {...});  

You can use ng-repeating events

 . You can also make directives for directives. (Directive ('NGRPAP'), function () {return {restrict: 'a', link: function (scope, element, etter) {if (scope. $ Last === true) {radius. NGRPAPT ');}}}});  

Use $ broadcast or $ emit based on your code hierarchy.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -