angularjs remove transclude wrappers from slots
Asked Answered
I

0

6

I have a simple directive with transclusion slots.

function wmFormControl() {
    return {
        replace: true,
        templateUrl: 'wm-form-control.htm',
        transclude: {
            label: '?label',
            hint: '?hint'
        }
    };
}

and template

<section>
    <span ng-transclude="label"></span>
    <div ng-transclude></div>
    <span ng-transclude="hint"></span>
</section>

this is a usage

<wm-form-control>
    <label>Label</label>
    Blah blah blah
    <hint>hint</hint>
</wm-form-control>

As a result I have:

<section>
    <span ng-transclude="label">
        <label>Label</label>
    </span>
    <div ng-transclude>
         Blah blah blah
    </div>
    <span ng-transclude="hint">
        <hint>hint</hint>
    </span>
</section>

Is there any way to remove slot wrappers? <label> and <hint> or the one with ng-transclude, for example?

What I want to get:

<section>
    <span ng-transclude="label">Label</span>
    <div ng-transclude>
         Blah blah blah
    </div>
    <span ng-transclude="hint">hint</span>
</section>
Improvvisatore answered 29/7, 2016 at 9:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.