Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng-content select does not work when content is in a *ng-for loop #3397

Closed
typotter opened this issue Jul 30, 2015 · 8 comments
Closed

ng-content select does not work when content is in a *ng-for loop #3397

typotter opened this issue Jul 30, 2015 · 8 comments

Comments

@typotter
Copy link

When providing an element selector to the ng-content tag, the contents are not transcluded.
Example:

my-component template

<div>My Items</div>
<ng-content select="my-item"></ng-content>

caller template

<my-component>
  <my-item *ng-for="#item of items">{{item}}</my-item>
<my-component>

In this example, the my-item components are not transcluded. If they are not in a for loop, then they are picked up. example:

<my-component>
  <my-item>Item 1</my-item>
  <my-item>Item 2</my-item>
<my-component>
@matanlurey
Copy link
Contributor

I think this is WAI, @tbosch would know best.

@tbosch
Copy link
Contributor

tbosch commented Jul 31, 2015

yes, this does not work right now. However, what does work is this:

<my-component>
  <template ng-for #item [of]="items" class="item"><my-item>{{item}}</my-item></template>
</my-component>

...
<ng-content select=".item">

I.e. we are checking the template element to be projected, as <my-item *ng-for> actually is just a shorthand for the above code. However, we probably want to support this case as well...

@kara
Copy link
Contributor

kara commented Sep 8, 2015

@tbosch The syntax in your example is now [ng-for-of] rather than [of], right?

  <template ng-for #item [ng-for-of]="items" class="item">

Here's a plunker of the working code for anyone else playing around with this:
http://plnkr.co/edit/Hn393B9fJN6zgfaz54tn

@tbosch
Copy link
Contributor

tbosch commented Sep 8, 2015

@kara yes, this is correct.

@woppa684
Copy link

Any update on when this will be fixed?

@tbosch
Copy link
Contributor

tbosch commented Jul 1, 2016

This should work as of aa966f5

@tbosch tbosch closed this as completed Jul 1, 2016
@uMaxmaxmaximus
Copy link

in my framework is works ^^ https://www.youtube.com/watch?v=tmKMAfzR8Ow

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
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

7 participants