Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Allow multiple transcluding directives on an element #4357

Closed
vojtajina opened this issue Oct 9, 2013 · 47 comments
Closed

Allow multiple transcluding directives on an element #4357

vojtajina opened this issue Oct 9, 2013 · 47 comments

Comments

@vojtajina
Copy link
Contributor

I believe it's possible, so let's try it.

@ravinggenius
Copy link

This may be a duplicate of #4350.

IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Oct 11, 2013
Issue an error and abort compilation when two directives that ask for transclusion are found
on a single element. This configuration is not supported and we previously failed to issue
the error because in the case of element transclusion the compilation is re-started and this
caused the compilation context to be lost.

The ngRepeat directive has been special-cased to bypass this warning because it knows how to
handle this scenario internally.

This is not an ideal solution to the problem of multiple transclusions per element, we are
hoping to have this configuration supported by the compiler in the future. See angular#4357.

Closes angular#3893
Closes angular#4217
Closes angular#3307
IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Oct 12, 2013
Issue an error and abort compilation when two directives that ask for transclusion are found
on a single element. This configuration is not supported and we previously failed to issue
the error because in the case of element transclusion the compilation is re-started and this
caused the compilation context to be lost.

The ngRepeat directive has been special-cased to bypass this warning because it knows how to
handle this scenario internally.

This is not an ideal solution to the problem of multiple transclusions per element, we are
hoping to have this configuration supported by the compiler in the future. See angular#4357.

Closes angular#3893
Closes angular#4217
Closes angular#3307
IgorMinar added a commit that referenced this issue Oct 12, 2013
Issue an error and abort compilation when two directives that ask for transclusion are found
on a single element. This configuration is not supported and we previously failed to issue
the error because in the case of element transclusion the compilation is re-started and this
caused the compilation context to be lost.

The ngRepeat directive has been special-cased to bypass this warning because it knows how to
handle this scenario internally.

This is not an ideal solution to the problem of multiple transclusions per element, we are
hoping to have this configuration supported by the compiler in the future. See #4357.

Closes #3893
Closes #4217
Closes #3307
@Narretz
Copy link
Contributor

Narretz commented Dec 18, 2013

+1

4 similar comments
@skonieczny
Copy link

+1

@dberringer
Copy link

+1

@dmytro-shchurov
Copy link

+1

@kevin-smets
Copy link

👍

@SimplGy
Copy link

SimplGy commented Jan 24, 2014

A great idea. Very much like the Marionette region concept, or ui-router's idea of sibling views, but constrained to a single directive. #4350 gives the example of a modal or something with a body and a title. You could also use this for window/side pane and other ui structures that have multiple content panes.

@SimplGy
Copy link

SimplGy commented Jan 24, 2014

jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
Issue an error and abort compilation when two directives that ask for transclusion are found
on a single element. This configuration is not supported and we previously failed to issue
the error because in the case of element transclusion the compilation is re-started and this
caused the compilation context to be lost.

The ngRepeat directive has been special-cased to bypass this warning because it knows how to
handle this scenario internally.

This is not an ideal solution to the problem of multiple transclusions per element, we are
hoping to have this configuration supported by the compiler in the future. See angular#4357.

Closes angular#3893
Closes angular#4217
Closes angular#3307
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
Issue an error and abort compilation when two directives that ask for transclusion are found
on a single element. This configuration is not supported and we previously failed to issue
the error because in the case of element transclusion the compilation is re-started and this
caused the compilation context to be lost.

The ngRepeat directive has been special-cased to bypass this warning because it knows how to
handle this scenario internally.

This is not an ideal solution to the problem of multiple transclusions per element, we are
hoping to have this configuration supported by the compiler in the future. See angular#4357.

Closes angular#3893
Closes angular#4217
Closes angular#3307
@quicksnap
Copy link

Great idea. Just came across a use case for this, wanting to transclude with an attribute directive after ng-include on the same element. Was hoping it would just priority-order the transcludes.

@thomaux
Copy link

thomaux commented Feb 20, 2014

+1

@DavidSouther
Copy link
Contributor

+1

This is IMHO one of the best parts of the Web Components / Shadow DOM spec

@cansin
Copy link

cansin commented Feb 27, 2014

+1

@aeharding
Copy link

+1

Needed for doing complex + awesome stuff. :-)

@blackgate
Copy link

+1

1 similar comment
@poshest
Copy link
Contributor

poshest commented Mar 28, 2014

+1

@gabrielmaldi
Copy link
Contributor

+1

I have an element directive with replace: true and transclude: true; when using it I apply another attribute directive to it that also transcludes. As @quicksnap, I expected the transclusions to respect the directives' priorities.

@caitp
Copy link
Contributor

caitp commented May 18, 2014

@Maxmaxmaximus what?

@DavidSouther
Copy link
Contributor

@Maxmaxmaximus it is a fantastic idea, it's just not been implemented yet. See also #7270

@jftsaraiva
Copy link

+1

@nickholub
Copy link

Got workaround for this when used in custom directive.
Idea is to capture content with one directive and transclude in the template with another.
Live demo http://nickholub.github.io/angular-composite-component
Source code https://github.com/nickholub/angular-composite-component

<div cs-composite>
    <div cs-section="header">
        Composite Component Header
    </div>
    <div cs-section="footer">
        Composite Component Footer
    </div>
</div>

@maroshii
Copy link

+1

@dlongley
Copy link
Contributor

One implementation of multi-transclude: https://github.com/zachsnow/ng-multi-transclude

@gusverdywid
Copy link

+1

3 similar comments
@ghost
Copy link

ghost commented Jan 2, 2015

+1

@dgroomes
Copy link

dgroomes commented Jan 2, 2015

+1

@Beaudinn
Copy link

Beaudinn commented Jan 8, 2015

+1

@goleafs
Copy link

goleafs commented Feb 13, 2015

+1 all day long

@dasois
Copy link

dasois commented Feb 16, 2015

+1

3 similar comments
@rschoenbichler
Copy link

+1

@jbro-io
Copy link

jbro-io commented Mar 20, 2015

+1

@yonatanbe
Copy link

+1

@moneytree-doug
Copy link

👍 Is this still on the roadmap?

@squadwuschel
Copy link

+1

@redaz808
Copy link

redaz808 commented Jul 2, 2015

+1

1 similar comment
@ro0sterjam
Copy link

+1

@trumbitta
Copy link

👍 :shipit:

@pablomaurer
Copy link

+1

2 similar comments
@dnord91
Copy link

dnord91 commented Aug 12, 2015

+1

@davidetrapani
Copy link

+1

@gabrielmaldi
Copy link
Contributor

This is being worked on in #12934

@schoettler
Copy link

+1

2 similar comments
@pankajparkar
Copy link

+1

@Ramon2000
Copy link

+1

@petebacondarwin
Copy link
Contributor

This feature is now in Angular 1.5.

@brunowego
Copy link

Thanks @petebacondarwin 👍

@ahmadhsalim
Copy link

ahmadhsalim commented Sep 6, 2016

There's a scenario which requires to allow multiple directives on same element that uses transclusion.
For eg: mdButton from angular materials library uses transclude: true. And I have created a directive called ifCan where I input permission slugs to show/hide the element. The ifCan directive has transclude: 'element'. This gives an error, eg:

Multiple directives [ifCan, mdButton (module: material.components.button)] asking for transclusion on: <md-button ui-sref="professionals.create" if-can="professionals.store" class="md-icon-button">

ngIf directive does the same thing with transclude: 'element' but it does not throw error due to a private property called $$tlb when declaring the directive. If there's a way to allow multiple transcluding directives without using a private property then it'll be solved. For now I'm using $$tlb: true as a workaround to fix this, which is actually unreliable because it's private.

@petebacondarwin
Copy link
Contributor

@ahmadhsalim - please create a new issue if you have a problem. It is best not to try to add on to close issues.

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

No branches or pull requests