Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When i use <nz-tabset> and <nz-tab>,create two tabs, as tab1 and tab2,when i open the page, tab1 and tab2 all print the console information #2716

Closed
julin69 opened this issue Dec 29, 2018 · 3 comments

Comments

@julin69
Copy link

julin69 commented Dec 29, 2018

Version

1.8.1

Environment

local

Reproduction link

https://ng-zorro-antd-start-bqptxw.stackblitz.io

Steps to reproduce

When i use and ,create two tabs, as tab1 and tab2,when i open the page, tab1 and tab2 all print the console information

What is expected?

when i open tab1,render tab1 content, and when i open tab2,render tab2 content

What is actually happening?

when i open tab1,tab1 and tab2 all print the console information

Other?

@julin69
Copy link
Author

julin69 commented Dec 29, 2018

The screenshoot is below:
image

@guobin211
Copy link

you need route

routes = [
{path: "tab1", component: Tab1Component},
{path: "tab2", component: Tab2Component}
]

html

<nz-tabset>
  <nz-tab nzTitle="tab1" (nzClick)=navTo("tab1")></nz-tab>
  <nz-tab nzTitle="tab2" (nzClick)=navTo("tab2")></nz-tab>
</nz-tabset>
<route-outlet></route-outlet>

ts

navTo(p) {
  this.route.navigate(p);
}

@wzhudev
Copy link
Member

wzhudev commented Dec 30, 2018

Known problem. Anything contains in <ng-content> would be created even if its DOM wouldn't be rendered, actually it's a feature (or bug?) of Angular. We would introduce another method to solve this problem in the future. For now you could use @guobin211 's method.

Actually, the method is used in material2 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants