forked from NG-ZORRO/ng-zorro-antd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:tabs): support link router (NG-ZORRO#3718)
- Loading branch information
Wendell
authored
Jul 18, 2019
1 parent
997c1f9
commit f6e9653
Showing
17 changed files
with
278 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 13 | ||
title: | ||
zh-CN: 路由联动 | ||
en-US: With Router | ||
--- | ||
|
||
## zh-CN | ||
|
||
与路由联动,点击 tab 更改路由,并且在路由改变时自动切换 tab。 | ||
|
||
## en-US | ||
|
||
Link with router. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-tabs-link-router', | ||
template: ` | ||
<nz-tabset nzLinkRouter> | ||
<nz-tab> | ||
<a nz-tab-link [routerLink]="['.']" [queryParams]="{ tab: 'one' }" queryParamsHandling="merge">Default</a> | ||
Default. | ||
</nz-tab> | ||
<nz-tab> | ||
<a nz-tab-link [routerLink]="['.']" [queryParams]="{ tab: 'two' }" queryParamsHandling="merge">Two</a> | ||
Two. | ||
</nz-tab> | ||
<nz-tab> | ||
<a nz-tab-link [routerLink]="['.']" [queryParams]="{ tab: 'three' }" queryParamsHandling="merge">Three</a> | ||
Three. | ||
</nz-tab> | ||
<nz-tab> | ||
<a nz-tab-link [routerLink]="['.']" [queryParams]="{ tab: 'four' }" queryParamsHandling="merge">Four</a> | ||
Four. | ||
</nz-tab> | ||
</nz-tabset> | ||
` | ||
}) | ||
export class NzDemoTabsLinkRouterComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @license | ||
* Copyright Alibaba.com All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE | ||
*/ | ||
|
||
import { Directive, Optional, Self } from '@angular/core'; | ||
import { RouterLink, RouterLinkWithHref } from '@angular/router'; | ||
|
||
/** | ||
* This component is for catching `routerLink` directive. | ||
*/ | ||
@Directive({ | ||
selector: 'a[nz-tab-link]', | ||
exportAs: 'nzTabLink' | ||
}) | ||
export class NzTabLinkDirective { | ||
constructor( | ||
@Optional() @Self() public routerLink?: RouterLink, | ||
@Optional() @Self() public routerLinkWithHref?: RouterLinkWithHref | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
<ng-template> | ||
<ng-template #titleTpl> | ||
<ng-content select="[nz-tab-link]"></ng-content> | ||
</ng-template> | ||
<ng-template #bodyTpl> | ||
<ng-content></ng-content> | ||
</ng-template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.