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

Proposal for multiple transclusion targets #4350

Closed
ravinggenius opened this issue Oct 9, 2013 · 14 comments
Closed

Proposal for multiple transclusion targets #4350

ravinggenius opened this issue Oct 9, 2013 · 14 comments

Comments

@ravinggenius
Copy link

When transcluding into a directive, it would be super useful to specify multiple targets. Polymer makes this easy with the <content /> element, together with the [select] attribute.

What I'm proposing is to allow [ng-transclude] (in the target directive template) to take an optional CSS selector, which would select content from the source (where the directive was used) and stick it into the appropriate place in the template. For instance:

<!-- foo directive usage -->
<foo>
  <p>Regular content goes here.</p>
  <foo-footer>
    <p>I show up in the footer.</p>
  </foo-footer>
</foo>
<!-- foo directive template -->
<div class="foo">
  <div class="foo-body" ng-transclude />
  <div class="foo-footer" ng-transclude="foo-footer" />
</div>
<!-- foo directive dom (after rendering) -->
<div class="foo">
  <div class="foo-body">
    <p>Regular content goes here.</p>
  </div>
  <div class="foo-footer">
    <p>I show up in the footer.</p>
  </div>
</div>
@DavidSouther
Copy link
Contributor

+1

@Wizek
Copy link

Wizek commented Apr 27, 2014

#7270 Is the main roadblock preventing this from happening as far as I can see.
#7240 is a related inconvenience, but it can be worked around.

@vanduc1102
Copy link

+1

2 similar comments
@douglas-treadwell
Copy link

+1

@bvaughn
Copy link

bvaughn commented Jun 26, 2014

+1

@douglas-treadwell
Copy link

https://github.com/wmluke/angular-blocks provides this functionality.

@nickholub
Copy link

Workaround for this can be implemented with 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>

@tonylampada
Copy link

+1

3 similar comments
@mucsi96
Copy link

mucsi96 commented Jul 21, 2014

+1

@dbwhddn10
Copy link
Contributor

+1

@giodamelio
Copy link

👍

@dgroomes
Copy link

dgroomes commented Jan 2, 2015

+1

@fernandopasik
Copy link

Web Components have this awesome feature, it would be awesome to have it in angular! :)

@Narretz Narretz modified the milestones: Ice Box, Backlog Sep 13, 2015
@Narretz
Copy link
Contributor

Narretz commented Oct 12, 2015

A feature like this will land in 1.5: a4ada8b :)

@Narretz Narretz closed this as completed Oct 12, 2015
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