Skip to content

Commit

Permalink
fix(module:tabs): repeat rendering the TabBarExtra when used nested t…
Browse files Browse the repository at this point in the history
…abs (#489)

close #452
  • Loading branch information
hsuanxyz authored and vthinkxie committed Nov 4, 2017
1 parent ad5bc29 commit 3289e7f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/tabs/nz-tabset.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type NzTabType = 'line' | 'card';
[nzHideBar]="nzHide"
[selectedIndex]="nzSelectedIndex">
<ng-template #tabBarExtraContent>
<ng-template [ngTemplateOutlet]="nzTabBarExtraContent"></ng-template>
<ng-template [ngTemplateOutlet]="nzTabBarExtraTemplate || nzTabBarExtraContent"></ng-template>
</ng-template>
<div
nz-tab-label
Expand Down Expand Up @@ -90,6 +90,7 @@ export class NzTabSetComponent implements AfterContentChecked, OnInit, AfterView
_selectedIndex: number | null = null;
_isViewInit = false;
_tabs: Array<NzTabComponent> = [];
@Input() nzTabBarExtraTemplate: TemplateRef<any>;
@ContentChild('nzTabBarExtraContent') nzTabBarExtraContent: TemplateRef<any>;
@ViewChild('tabNav') _tabNav: NzTabsNavComponent;
@ViewChild('tabContent') _tabContent: ElementRef;
Expand Down
4 changes: 2 additions & 2 deletions src/showcase/nz-demo-tabs/nz-demo-tabs-extra.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { Component, OnInit } from '@angular/core';
@Component({
selector: 'nz-demo-tabs-extra',
template: `
<nz-tabset>
<nz-tabset [nzTabBarExtraTemplate]="tabBarExtraContent">
<nz-tab *ngFor="let tab of tabs">
<ng-template #nzTabHeading>
Tab {{tab.index}}
</ng-template>
<span>Content of tab {{tab.index}}</span>
</nz-tab>
<ng-template #nzTabBarExtraContent>
<ng-template #tabBarExtraContent>
<button nz-button>Extra Action</button>
</ng-template>
</nz-tabset>`,
Expand Down
6 changes: 6 additions & 0 deletions src/showcase/nz-demo-tabs/nz-demo-tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ <h3 id="Tabs"><span>nz-tabset</span>
<td>Boolean</td>
<td>true</td>
</tr>
<tr>
<td>nzTabBarExtraTemplate</td>
<td>用于指定 tab bar 上特定的额外的元素</td>
<td>TemplateRef</td>
<td></td>
</tr>
<tr>
<td>#nzTabBarExtraContent</td>
<td>tab bar 上额外的元素</td>
Expand Down

0 comments on commit 3289e7f

Please sign in to comment.