All,
first off, see the Fiddle: http://jsfiddle.net/kbjorklid/2ndFc/
I have a situation where I needed (or wanted) to have two directives on the
same element. One directive creates a menu (I'll call this MenuDirective
later on) with ng-repeat (repeating over a set of links to create menu
items), the other directive adds a CSS class to the "active" menu item (I
will call this the DomManipulationDirective later on).
The problem I was having was that the MenuDirective would not create its
DOM structure before the DomManipulationDirective tried to manipulate it.
That is, zero <li> elements were found by the DomManipulationDirective even
though they could be seen in the resulting HTML. After trying a lot of
different things, I finally found a solution: I wrapped everything of the
DomManipulationDirective's link function inside a setTimeout(function() {
... }); and it worked.
Now, as I am trying to learn to code Angluar the right way, my question is:
is this the most elegant way of doing this or have I missed something?
Thank you in advance.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.