-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
在ModalHelper中使用st组件,会出现 NullInjectorError: No provider for _NzContextMenuService,导致弹出框页面无法加载 #2479
Comments
Translation of this issue:Use ST components in Modalhelper, and NULLLINJECTORRORRRRORRRRORORRRRORRORROROVIDER FORREPRODUCTION LINK[http://github.com/skmbw/ng-alain-17.2.0. STEPS To ReproduceUse ST components in Modalhelper, and NULLLINJECTORRORRRRORRRRORORRRRORRORROROVIDER FOR What is exfected?Open the pop -up box normally What is actually happy?Can't open the pop -up box | ENVIRONMENT | Info | |
错误出现在文件st.component.mjs的113行,this.cms = inject(NzContextMenuService); |
就像这样,ModalHelper.createStatic(DataRuleGroupEditComponent......,创建模态框,如果DataRuleGroupEditComponent(模态框要弹出的组件,包含st组件),模态框将无法渲染 |
使用standalone component,NgModule中imports当前component
|
@skmbw 我也不无重现出你所说的情况 ,png: |
你这个方法是对的。组件要在modal中弹出,如果是NgModule组件,且组件中使用了st组件,是会报缺少注入器,无法使用inject方法注入NzContextMenuService,如果不包含st组件,是没问题的;如果组件是standalone组件,包含或者不包含st组件,都是不会报错的。因为我原来很多组件都是NgModule组件,不是standalone组件,一个一个改为standalone,太费时。我的解决方法是,将NzContextMenuService改为使用构造函数注入,不使用inject方法注入,这样就没有问题了。 |
组件要在modal中弹出,如果是NgModule组件,且组件中使用了st组件,是会报缺少注入器,无法使用inject方法注入NzContextMenuService,如果不包含st组件,是没问题的;如果组件是standalone组件,包含或者不包含st组件,都是不会报错的。因为我原来很多组件都是NgModule组件,不是standalone组件,一个一个改为standalone,太费时。我的解决方法是,将st.component中的NzContextMenuService改为使用构造函数注入,不使用inject方法注入,这样就没有问题了。那么引申出来一个问题,为什么NzContextMenuService可以使用构造函数注入,不能使用inject方法注入,我就没有深入研究了。 |
同遇到了,现在改为standalone好了 |
具体是咋改?更改node_modules中的代码? |
Reproduction link
http://github.com/skmbw/ng-alain-17.2.0
Steps to reproduce
在ModalHelper中使用st组件,会出现 NullInjectorError: No provider for _NzContextMenuService,导致弹出框页面无法加载
What is expected?
正常打开弹出框
What is actually happening?
打不开弹出框
The text was updated successfully, but these errors were encountered: