Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Nested transclusions don't work as expected #8

Closed
zachsnow opened this issue Jul 29, 2014 · 4 comments
Closed

Nested transclusions don't work as expected #8

zachsnow opened this issue Jul 29, 2014 · 4 comments

Comments

@zachsnow
Copy link
Owner

Consider a regular multi-transclude template:

<ul>
    <li ng-multi-transclude="mainItem" class="main"></li>
    <li ng-multi-transclude="secondaryItem" class="secondary"></li>
    <li class="extra">An extra item.</li>
</ul>

There are two blocks to be filled. Now we might want to wrap the secondaryItem block in an ng-repeat so we can use it for several secondary items:

<ul>
    <li ng-multi-transclude="mainItem" class="main"></li>
    <li ng-repeat="secondary in secondaries" class="secondary">
        <span ng-multi-transclude="secondaryItem"></span>
    </li>
    <li class="extra">An extra item.</li>
</ul>

This currently doesn't work (and certainly wouldn't work if we put the ng-repeat on the same element as the ng-multi-transclude). But it would be cool if it did.

See #5 for the original issue.

@thejohnfreeman
Copy link

Howdy Zach, your module is great, but this limitation encouraged me to write my own solution, ng-temple. Please check it out and let me know what you think.

Here's a Plunker showing how it handles this issue.

@zachsnow
Copy link
Owner Author

Hey John, thanks for the link! I'm checking it out.

@zachsnow
Copy link
Owner Author

@thejohnfreeman it is a nice simplification to just require library consumers to use the compile function returned from ngTemplate, maybe I should stop trying to integrate with regular transclusion so much... Thanks again.

@zachsnow
Copy link
Owner Author

The above example doesn't make sense in terms of regular transclusion, in which the nodes to be inserted into the template "hole" are expected to be compiled and linked in the context in which they appear, and then inserted into the hole. In this example we want to link them in the context of the hole (presumably so that the object secondary is available in the secondary template). We will probably need to add a different directive for that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants