admin管理员组文章数量:1401368
I have components as follows
S1 (stand-alone)
N1 (Non standalone) Base component auth-Module
Now I am using S1 in Base component and N1 in S1 and getting the circular dependency. Can you please help resolve it.
I have components as follows
S1 (stand-alone)
N1 (Non standalone) Base component auth-Module
Now I am using S1 in Base component and N1 in S1 and getting the circular dependency. Can you please help resolve it.
Share Improve this question asked Mar 25 at 4:52 praneethpraneeth 91 bronze badge3 Answers
Reset to default 1Use Dependency Injection to Break the Cycle
Instead of directly importing N1 in S1, refactor N1 into a service and inject it into S1 instead of using it as a component.
First of all i think you have to make your ni component standalone as well.
Things you may understand
1: use the di instead of direct import
2: make an common service for repeating thing like we create for mui components
3: use lazy loading with nested routing in you project
In the BaseComponent
add the import with forwardRef
, this will help you avoid circular dependencies error.
@Component({
...
imports: [
...
forwardRef(() => S1Component),
...
],
...
})
BaseComponent {
...
本文标签: typescriptHow to resolve circular dependency in angularStack Overflow
版权声明:本文标题:typescript - How to resolve circular dependency in angular - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744217375a2595700.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论