You can read full article on the Infragistics blog In this article, we will learn to create a component dynamically. You may need to load a component dynamically in various scenarios such as want to show a popup modal etc. Let us assume that, we have a component as listed below, which we will load dynamically. To load MessageComponent dynamically you need a container. Let us say that we want to load MessageComponent inside AppComponent. We need a container element in the AppComponent. Template of AppComponent is as below: As you see that, we have an entry point template or a container template in which we will load MessageComponent dynamically. In the AppComponent, we need to import following: ViewChild, ViewContainerRef, and ComponentFactoryResolver from @angular/core ComponentRef and ComponentFactory from @angular/core MessageComponent from message.component After importing required things, AppComponnet will look like following listing: We can access template as the ViewChild inside the Component class.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
angular,Component
angular,Component
0 Comments