typescript - Angular: Maintaining a map or dictionary of component types - Stack Overflow

I have come over to the community to find some wisdom.I have currently migrated my project from angula

I have come over to the community to find some wisdom. I have currently migrated my project from angular 12 to angular 19.

To that end I want to maintain a map or dictionary of components which I would use to render these components dynamically via a service which gets the type of the component based on the string key provided and renders it via view container ref.

const componentMap =  {
"comp1": Component1,
"comp2": Component2,
}

But in keeping the map of components I run into obvious circular dependency DI/compile time issues. It worked fine with angular 12 and I know its poor code. So now I was scouring the web for maintaining a map/dictionary of component types/ component references which can then be used with viewContainerRef to render component. I could not find any best practises for doing that. Hence I am here to ask for help from the community and gain some knowledge in the process. Thanks for the help in advance.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744250956a4565164.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信