Skip to content

Commit dc6591f

Browse files
committed
fix: allow content projection and templates to be rendered at the same time
Signed-off-by: Akshat Patel <[email protected]>
1 parent 90fd15e commit dc6591f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/tabs/tab.component.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ import {
6363
[ngStyle]="{'display': active ? null : 'none'}"
6464
[attr.aria-labelledby]="id + '-header'"
6565
aria-live="polite">
66-
<ng-template *ngIf="isTemplate(tabContent); else projectedContent" [ngTemplateOutlet]="tabContent"></ng-template>
67-
</div>
68-
<ng-template #projectedContent>
66+
<ng-template *ngIf="isTemplate(tabContent)" [ngTemplateOutlet]="tabContent" [ngTemplateOutletContext]="{ $implicit: templateContext }"></ng-template>
6967
<ng-content></ng-content>
70-
</ng-template>
68+
</div>
7169
`
7270
})
7371
export class Tab implements OnInit {
@@ -114,14 +112,18 @@ export class Tab implements OnInit {
114112
@Input() set cacheActive(shouldCache: boolean) {
115113
this._cacheActive = shouldCache;
116114
}
117-
115+
/**
116+
* Allows life cycle hooks to be called on the rendered content
117+
*/
118118
@Input() tabContent: TemplateRef<any>;
119-
119+
/**
120+
* Optional data for templates passed as implicit context
121+
*/
122+
@Input() templateContext: any;
120123
/**
121124
* Value 'selected' to be emitted after a new `Tab` is selected.
122125
*/
123126
@Output() selected: EventEmitter<void> = new EventEmitter<void>();
124-
125127
/**
126128
* Used to set the id property on the element.
127129
*/

0 commit comments

Comments
 (0)