Check out https://toddmotto.com/transclusion-in-angular-2-with-ng-content.

I think you want one of the following: (check out 
https://toddmotto.com/transclusion-in-angular-2-with-ng-content)


<myComponent>
  <div class="myTemplateContent">test</div>
</myComponent>


<div *ngFor="let a of myList">
{{a}}<ng-content select=".myTemplateContent"></ng-content>
</div>

OR

<myComponent>
  <myTemplateContent>test</myTemplateContent>
</myComponent>


<div *ngFor="let a of myList">
{{a}}<ng-content select="myTemplateContent"></ng-content>
</div>





On Wednesday, October 5, 2016 at 7:42:23 AM UTC-4, Christophe HOARAU wrote:
>
> Hi,
>
> I would like to know if its possible to define a template(transclusion), 
> then call it inside a for loop in the directive template.
> I have tried but it does nothing, no error and no content is generated in 
> my loop.
>
> Here is a sample of the code :
>
> <myComponent>
>   <div myTemplateContent>test</div>
> </myComponent>
>
>
> then in "myComponent" code I have :
> <div *ngFor="let a of myList">
> {{a}}<ng-content select="[myTemplateContent]"></ng-content>
> </div>
>
> in this case ng-content renders nothing at all.
>
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to