简体   繁体   中英

Add content to dynamically created tabs - Angular 7

So I've got a page where I'm dynamically creating tabs based on Nav selection. I'm wondering how I can add/load the component I need into the tab I just created. I've been searching around and I've landed on and trying to use the selector but I'm not sure I'm doing it right, or even if this is the best method.

I didn't want to clutter up this post with a bunch of code so I've created an example of what I've tried here: https://stackblitz.com/edit/angular-jx4zxb

I have a feeling this line isn't right, but I'm not sure.

<ng-content select="[tab.selector]"></ng-content>

Thank you for any help!

ABOS answered my question in the comments. They provided a link to my edited stackblitz here: https://stackblitz.com/edit/angular-jx4zxb-saeflu?file=app%2Ftab-group-dynamic-example.html

There are a few changes from my original so be sure to grab them all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM