File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -63,8 +63,12 @@ import {
6363 [ngStyle]="{'display': active ? null : 'none'}"
6464 [attr.aria-labelledby]="id + '-header'"
6565 aria-live="polite">
66- <ng-content ></ng-content >
66+ <ng-template *ngIf="isTemplate(tabContent); else projectedContent" [ngTemplateOutlet]="tabContent" ></ng-template >
6767 </div>
68+ <ng-template #projectedContent>
69+ <ng-content></ng-content>
70+ </ng-template>
71+
6872 `
6973} )
7074export class Tab implements OnInit {
@@ -111,6 +115,9 @@ export class Tab implements OnInit {
111115 @Input ( ) set cacheActive ( shouldCache : boolean ) {
112116 this . _cacheActive = shouldCache ;
113117 }
118+
119+ @Input ( ) tabContent : TemplateRef < any > ;
120+
114121 /**
115122 * Value 'selected' to be emitted after a new `Tab` is selected.
116123 */
@@ -150,4 +157,8 @@ export class Tab implements OnInit {
150157 shouldRender ( ) {
151158 return this . active || this . cacheActive ;
152159 }
160+
161+ public isTemplate ( value ) {
162+ return value instanceof TemplateRef ;
163+ }
153164}
Original file line number Diff line number Diff line change @@ -27,11 +27,24 @@ const Template = (args) => ({
2727 [followFocus]="followFocus"
2828 [isNavigation]="isNavigation"
2929 [cacheActive]="cacheActive">
30- <cds-tab heading="one">Tab Content 1 </cds-tab>
31- <cds-tab heading="two">Tab Content 2 </cds-tab>
32- <cds-tab heading="three">Tab Content 3 </cds-tab>
30+ <cds-tab heading="one" [tabContent]="one"> </cds-tab>
31+ <cds-tab heading="two" [tabContent]="two"> </cds-tab>
32+ <cds-tab heading="three" [tabContent]="three"> </cds-tab>
3333 <cds-tab heading="three">Tab Content 3</cds-tab>
3434 </cds-tabs>
35+
36+
37+ <ng-template #one>
38+ Tab Content 1
39+ </ng-template>
40+
41+ <ng-template #two>
42+ Tab Content 2
43+ </ng-template>
44+
45+ <ng-template #three>
46+ Tab Content 3
47+ </ng-template>
3548 `
3649} ) ;
3750export const Basic = Template . bind ( { } ) ;
You can’t perform that action at this time.
0 commit comments