Angular Modal with Dynamic component on run time.

How to create modal on runtime in Angular?

In my pervious post i have shown you how to created modal with just showing and hiding component. But now in this post i will show you we can load dynamically using ComponentFactoryResolver and ViewContainerRef on runtime. Some time it is our requirement where we need to load component on run time that is what iam doing here on click loading component on run time. With ComponentFactoryResolver we are creating component and with ViewContainerRef we are giving reference with the use of where to show this modal we can also pass method and property to modal component. If you want to see pervious post Click here.

Demo Githhub Stackblitz

43 thoughts on “Angular Modal with Dynamic component on run time.

Leave a Reply

Your email address will not be published. Required fields are marked *