Skip to content

Commit 442b4fe

Browse files
committed
feat(tabs/bottomNav): template support for tab items #4297
1 parent b932b71 commit 442b4fe

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

projects/igniteui-angular/src/lib/tabbar/tabbar.component.ts

+7
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,10 @@ export class IgxTabComponent {
615615
@ViewChild('defaultTabTemplate', { read: TemplateRef })
616616
protected defaultTabTemplate: TemplateRef<any>;
617617

618+
/**@hidden*/
619+
@ContentChild(IgxTabTemplateDirective, { read: IgxTabTemplateDirective })
620+
protected customTabTemplateDir: IgxTabTemplateDirective;
621+
618622
/**
619623
* Returns the `template` for this IgxTabComponent.
620624
* ```typescript
@@ -626,6 +630,9 @@ export class IgxTabComponent {
626630
if (this.relatedPanel && this.relatedPanel.customTabTemplate) {
627631
return this.relatedPanel.customTabTemplate;
628632
}
633+
if (this.customTabTemplateDir) {
634+
return this.customTabTemplateDir.template;
635+
}
629636
return this.defaultTabTemplate;
630637
}
631638

projects/igniteui-angular/src/lib/tabs/tab-item.component.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
Component,
3+
ContentChild,
34
ElementRef,
45
HostBinding,
56
HostListener,
@@ -10,6 +11,7 @@ import {
1011

1112
import { IgxTabsGroupComponent } from './tabs-group.component';
1213
import { IgxTabItemBase, IgxTabsBase } from './tabs.common';
14+
import { IgxTabItemTemplateDirective } from './tabs.directives';
1315

1416
@Component({
1517
selector: 'igx-tab-item',
@@ -72,6 +74,10 @@ export class IgxTabItemComponent implements IgxTabItemBase {
7274
@ViewChild('defaultTabTemplate', { read: TemplateRef })
7375
protected defaultTabTemplate: TemplateRef<any>;
7476

77+
/**@hidden*/
78+
@ContentChild(IgxTabItemTemplateDirective, { read: IgxTabItemTemplateDirective })
79+
protected customTabTemplateDir: IgxTabItemTemplateDirective;
80+
7581
private _nativeTabItem: ElementRef;
7682
private _changesCount = 0; // changes and updates accordingly applied to the tab.
7783
private _isSelected = false;
@@ -278,6 +284,9 @@ export class IgxTabItemComponent implements IgxTabItemBase {
278284
if (this.relatedGroup && this.relatedGroup.customTabTemplate) {
279285
return this.relatedGroup.customTabTemplate;
280286
}
287+
if (this.customTabTemplateDir) {
288+
return this.customTabTemplateDir.template;
289+
}
281290
return this.defaultTabTemplate;
282291
}
283292

src/app/bottomnav-routing/bottomnav-routing.sample.html

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
routerLink="/bottom-navigation-routing/view3"
2727
routerLinkActive #rla3="routerLinkActive"
2828
[isSelected]="rla3.isActive">
29+
<ng-template igxTab let-context>
30+
<span>{{context.label}}</span>
31+
<span>[Retemplated tab]</span>
32+
</ng-template>
2933
</igx-tab>
3034

3135
</igx-bottom-nav>

src/app/tabs-routing/tabs-routing.sample.html

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ <h3 class="sample-title">Routing sample</h3>
2424
routerLink="/tabs-routing/view3"
2525
routerLinkActive #rla3="routerLinkActive"
2626
[isSelected]="rla3.isActive">
27+
<ng-template igxTab let-context>
28+
<span>{{context.label}}</span>
29+
<span>[Retemplated tab]</span>
30+
</ng-template>
2731
</igx-tab-item>
2832
</igx-tabs>
2933
<div>

0 commit comments

Comments
 (0)