<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dimpu Aravind Buddha on Medium]]></title>
        <description><![CDATA[Stories by Dimpu Aravind Buddha on Medium]]></description>
        <link>https://medium.com/@dimpu?source=rss-740fa2ff370e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xGAZi1WqSSknrs5D.jpeg</url>
            <title>Stories by Dimpu Aravind Buddha on Medium</title>
            <link>https://medium.com/@dimpu?source=rss-740fa2ff370e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 03:30:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dimpu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Real Dynamic Components Creation in Angular 4+]]></title>
            <link>https://medium.com/@dimpu/real-dynamic-components-creation-in-angular-4-6401d644898e?source=rss-740fa2ff370e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6401d644898e</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[advanced]]></category>
            <dc:creator><![CDATA[Dimpu Aravind Buddha]]></dc:creator>
            <pubDate>Wed, 29 Aug 2018 05:35:06 GMT</pubDate>
            <atom:updated>2018-08-29T17:16:25.488Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncWRaVSdOJdAKDHJ7O3wPg.png" /><figcaption>Dynamic Component Creation In Angular</figcaption></figure><p>Alright, as much as I love new Angular framework there are few pain points in here. One of them Is creating dynamic Angular components.</p><p>There are lot of confusing blog posts that attempt to explain Angular Dynamic Component Loading rather than creation.</p><p>The solution for creating Dynamic Angular Component may not be as easy as AngualrJs solution of using $compile to create dynamic components. But it’s not that difficult also.</p><p>When I google around for creating dynamic components in Angular 4+ All I’m getting is similar to what we have it on official angular docs dynamic angular loader(<a href="https://angular.io/guide/dynamic-component-loader">https://angular.io/guide/dynamic-component-loader</a>) Which is totally different thing. I’m not going to explain this here but If you go that docs, you will see that what ever the component that you want to load we have create it and then pass it to `entryComponents` array in a module. But what we really want is to build a angular component just by passing template and other properties to it.</p><p>The solution involves following steps.</p><ol><li>Create Component</li><li>Create Module</li><li>Compile module using compailer.compileModuleAndAllComponentsSync</li><li>Create a ViewChild Container @ViewChild(&quot;container&quot;, {read:ViewContainerRef}) container: ViewContainerRef;</li><li>Get the component factory from module.</li><li>Create a component instance using ViewChild container reference.</li><li>Attach properties to component instance.</li><li>(optional) trigger change detection. Similar to AngularJs $rootScope.$digest()</li></ol><p>Looks Like lot of steps right. Ya it is but good news is you have create it once and use as as simple function call from service.</p><p>Let’s Create Angular Service for this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6154f262bdb17bc73287c092003a4795/href">https://medium.com/media/6154f262bdb17bc73287c092003a4795/href</a></iframe><p>Here you don’t see step 4 of using @VeiwChild to create container that we will see now.</p><p>Now, Create Component which will use this Services.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7bfdd1f8bd8ab1407cabfc1cbd6bcd76/href">https://medium.com/media/7bfdd1f8bd8ab1407cabfc1cbd6bcd76/href</a></iframe><p>Here we created the ViewChild ref element and pass it to addComponent function on dynamicComponentService.</p><p>Thanks. Hope you enjoy this new way of creating dynamic component in Angular framework.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6401d644898e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>