Angularjs remove transclude wrappers from slots

I have a simple directive with slots for migration.

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

and pattern

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

this use

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

As a result, I:

<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 a way to remove slot wrappers? <label>and <hint>or 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>
+4
source share

Source: https://habr.com/ru/post/1649510/


All Articles