zachsnow / ng-multi-transclude

ng-multi-transclude
MIT License
79 stars 19 forks source link

Nested transclusions don't work as expected #8

Closed zachsnow closed 10 years ago

zachsnow commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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

zachsnow commented 10 years ago

@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 commented 10 years ago

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.