zachsnow / ng-multi-transclude

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

using ng-multi-transclude within another ng-multi-transcluded directive. #14

Closed jusopi closed 9 years ago

jusopi commented 9 years ago

plnkr - http://plnkr.co/edit/BZfv8NVwD9VraJC5GVoN?p=preview

I'm trying to build a series of 'components' using your ng-multi-transclude directive. In a normal use case this is perfect. But when trying to 'subclass' directives (the best way I can think of the usage paradigm), I get an error Illegal use of ngMultiTransclude. No wrapping controller

I have added the ng-multi-transclude-controller at the top level tag in the 'subclass' and I have also moved it down further into the template (which produces no error). A normal ng-transclude tag works as expected (for instance in the case of the title controls in my example.

zachsnow commented 9 years ago

To be clear, here's an outline of what we're trying to accomplish as I understand the issue:

    <div class="panel">
        <h1 ng-multi-transclude="panel-title"></h1>
        <div ng-multi-transclude="panel-body"></div>
    </div>
    <div class="specialized-panel">
        <div panel>
            <div name="panel-title">
                Special title: <span ng-multi-transclude="special-panel-title"></span>
            </div>
            <div name="panel-body">
                <h2 ng-multi-transclude="special-sub-title"></h2>
                <div ng-multi-transclude="special-body"></div>
            </div>
        </div>
    </div>

Does that all sound right?

jusopi commented 9 years ago

Yes that sounds right.

Now I don't want to detract from the issue at hand but the ideal solution to this would to allow the specialized-panel instance to transclude content all the way down to the base panel template... much like inheritance works such that you are exposing these transclusion-container targets from any descendant. This would then negate the above bug/feature request if it could be implemented.

joepb commented 9 years ago

Is there any idea for a workaround here? This is quite an annoying bug, since now I have to be aware of all functionality used inside templates for directives, all the way down the tree.

The issue seems to come from the rendering/transclusion of the outer template. When this happens, the parts that are evaluated (and try to start more multi-transclusions), aren't part of the tree at that time. They get added to the tree later. And therefore they cannot find their controllers...

jusopi commented 9 years ago

@joepb I haven't visited this issue anymore since I just implemented what you alluded to (in this case I am only doing 2 levels of multi-transclude and am using unique names for the internal content).

But one thing that has come to mind after re-reading this whole issue is this: Have you tried setting a higher priority on the outer wrapping directive? I will try to test this here shortly.

zachsnow commented 9 years ago

I believe that the issue is that controllers are not correctly available when transcluding (see #18 for another example); I'm looking at this and will try to release a fix soon. Apologies for the delay.

zachsnow commented 9 years ago

This should be fixed in master.