I've got a "multi-transclude" service in my application which simply calls
the $transclude function in a directive's postLink function and does a
mapping of elements with "transclude-id" in the directive's template to
elements with "transclude-to" in the transcluded content.
For instance, the directive's template might look like this:
myDirective:
<div>
<div transclude-id="top"></div>
<div>Hello World</div>
</div transclude-id="bottom"></div>
</div>
And the usage might look like this:
<my-directive>
<div transclude-to="top">I'm above."</div>
<div transclude-to="bottom">I'm below.</div>
</my-directive>
Everything works fine until I try to use it with transcluded content that
also contains an ng-if directive, for instance:
<my-directive>
<div transclude-to="top" ng-if="showTop">I'm above."</div>
<div transclude-to="bottom">I'm below.</div>
</my-directive>
In this scenario, by the time I call the $transclude function, the element
with ng-if on it has already been replaced by a comment node: <!-- ngIf:
showTop --> So when my service examines the node it does not find the
transclude-to attribute and thus does not place it correctly.
I tried changing priority to make it higher (or lower) than ng-if but no
matter what I try it is always already replaced by that node.
Does anyone have any insight as to what is going on? I verified that my
directive is being called before ng-if's link function, yet it's still gone
during this call:
$transclude($scope, function(clone) {
// the clone nodeList contains the comment instead of the
transclude-to="top" node :(
});
Thanks!
--
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/d/optout.