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

无法在loadChildren后的子路由中使用nz组件 #151

Closed
HereWeR opened this issue Aug 25, 2017 · 3 comments · Fixed by #166
Closed

无法在loadChildren后的子路由中使用nz组件 #151

HereWeR opened this issue Aug 25, 2017 · 3 comments · Fixed by #166
Assignees
Labels

Comments

@HereWeR
Copy link

HereWeR commented Aug 25, 2017

I'm submitting a...


[ ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Support request => Please do not submit support request here

Current behavior

在配置好路由RouterModule.forRoot(appRouters)后,通过{path: 'main', loadChildren: './main/main.module#MainModule'}懒加载之后的模块无法使用nz组件,
报错为:ERROR Error: Uncaught (in promise): Error: Template parse errors:
'nz-dropdown' is not a known element:

  1. If 'nz-dropdown' is an Angular component, then verify that it is part of this module.
  2. If 'nz-dropdown' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("


    [ERROR ->]
    more </"): ng:///ItemsModule/TodoComponent.html@29:4
    Error: Template parse errors:
    'nz-dropdown' is not a known element:
  3. If 'nz-dropdown' is an Angular component, then verify that it is part of this module.
  4. If 'nz-dropdown' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

Expected behavior

希望支持下级module引用

Minimal reproduction of the problem with instructions

{path: '', redirectTo: 'main', pathMatch: 'full'},
{path: 'main', loadChildren: './main/main.module#MainModule'},
{path: 'setting', loadChildren: './setting/setting.module#SettingModule'},

import: BrowserAnimationsModule,
NgZorroAntdModule.forRoot(),
RouterModule.forRoot(appRouters)

What is the motivation / use case for changing the behavior?

最后一个module需要再次import引用NgZorroAntdModule,无法实现“在根 module 中使用 NgZorroAntdModule.forRoot(),在子 module 中使用 NgZorroAntdModule 即可”,望提供解决方案

Environment

angular-cli:“1.3.0”
ng-zorro-antd: "^0.5.0-rc.2"


Angular version: X.Y.Z

ng-zorro-antd version: X.Y.Z

Browser:
- [ x ] Chrome (desktop) version 59.0
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] IE version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@HereWeR HereWeR changed the title 无法再loadChildren后的子路由中使用nz组件 无法在loadChildren后的子路由中使用nz组件 Aug 25, 2017
@vthinkxie
Copy link
Member

vthinkxie commented Aug 25, 2017

You have to import NgZorroAntdModule in your sub module and it is the design of Angular, you may misunderstand the doc.
We will change the doc next version.
thanks for your feedback.

@vthinkxie vthinkxie self-assigned this Aug 25, 2017
@vthinkxie vthinkxie reopened this Aug 25, 2017
@cipchk
Copy link
Member

cipchk commented Aug 25, 2017

推荐比较合理的做法是在 SharedModule 中导入 NgZorroAntdModule 并导出。

@lock
Copy link

lock bot commented Feb 19, 2019

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants