Skip to content

Commit

Permalink
feat(module:tabs): add router exact active parameter (#3862)
Browse files Browse the repository at this point in the history
close #3858
  • Loading branch information
Wendell authored Aug 9, 2019
1 parent 583eb77 commit 6b13faf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion components/tabs/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import { NzTabsModule } from 'ng-zorro-antd/tabs';
| `[nzTabBarGutter]` | The gap between tabs | `number` | - |
| `[nzHideAll]` | Whether hide all tabs | `boolean` | `false` |
| `[nzShowPagination]` | Whether show pre or next button when exceed display area | `boolean` | `true` |
| `[nzLinkRouter]` | Link with Angular router. It supports child mode and query param mode | `boolean` | `false` ||
| `[nzLinkRouter]` | Link with Angular router. It supports child mode and query param mode | `boolean` | `false` |
| `[nzLinkExact]` | Use exact routing matching | `boolean` | `true` |
| `(nzSelectedIndexChange)` | Current tab's index change callback | `EventEmitter<number>` | - |
| `(nzSelectChange)` | Current tab's change callback | `EventEmitter<{nzSelectedIndex: number,tab: NzTabComponent}>` | - |
| `(nzOnNextClick)` | Callback executed when next button is clicked | `EventEmitter<void>` | - |
Expand Down
3 changes: 2 additions & 1 deletion components/tabs/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import { NzTabsModule } from 'ng-zorro-antd/tabs';
| `[nzTabBarGutter]` | tabs 之间的间隙 | `number` | - |
| `[nzHideAll]` | 是否隐藏所有tab内容 | `boolean` | `false` |
| `[nzShowPagination]` | 是否超出范围时显示pre和next按钮 | `boolean` | `true` |
| `[nzLinkRouter]` | 与 Angular 路由联动 | `boolean` | `false` ||
| `[nzLinkRouter]` | 与 Angular 路由联动 | `boolean` | `false` |
| `[nzLinkExact]` | 以严格匹配模式确定联动的路由 | `boolean` | `true` |
| `(nzSelectedIndexChange)` | 当前激活 tab 面板的 序列号变更回调函数 | `EventEmitter<number>` | - |
| `(nzSelectChange)` | 当前激活 tab 面板变更回调函数 | `EventEmitter<{nzSelectedIndex: number,tab: NzTabComponent}>` | - |
| `(nzOnNextClick)` | next 按钮被点击的回调 | `EventEmitter<void>` | - |
Expand Down
5 changes: 3 additions & 2 deletions components/tabs/nz-tabset.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class NzTabSetComponent
@ContentChildren(NzTabComponent) listOfNzTabComponent: QueryList<NzTabComponent>;
@ViewChild(NzTabsNavComponent, { static: false }) nzTabsNavComponent: NzTabsNavComponent;
@ViewChild('tabContent', { static: false }) tabContent: ElementRef;

@Input() nzTabBarExtraContent: TemplateRef<void>;
@Input() nzShowPagination = true;
@Input() nzAnimated: NzAnimatedInterface | boolean = true;
Expand All @@ -97,7 +98,7 @@ export class NzTabSetComponent
@Input() nzType: NzTabType = 'line';

@Input() @InputBoolean() nzLinkRouter = false;
@Input() nzQueryParam: string;
@Input() @InputBoolean() nzLinkExact = true;

@Output() readonly nzOnNextClick = new EventEmitter<void>();
@Output() readonly nzOnPrevClick = new EventEmitter<void>();
Expand Down Expand Up @@ -340,6 +341,6 @@ export class NzTabSetComponent
}

private isLinkActive(router: Router): (link?: RouterLink | RouterLinkWithHref) => boolean {
return (link?: RouterLink | RouterLinkWithHref) => (link ? router.isActive(link.urlTree, true) : false);
return (link?: RouterLink | RouterLinkWithHref) => (link ? router.isActive(link.urlTree, this.nzLinkExact) : false);
}
}

0 comments on commit 6b13faf

Please sign in to comment.