<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: puneet</title>
    <description>The latest articles on DEV Community by puneet (@gupta).</description>
    <link>https://dev.to/gupta</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1172977%2Fa7dedec3-75a6-45c4-a4c1-2306e7eeec97.png</url>
      <title>DEV Community: puneet</title>
      <link>https://dev.to/gupta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gupta"/>
    <language>en</language>
    <item>
      <title>I have issue in creating dynamic components at AOT angular 16</title>
      <dc:creator>puneet</dc:creator>
      <pubDate>Fri, 29 Sep 2023 09:07:27 +0000</pubDate>
      <link>https://dev.to/gupta/i-have-issue-in-creating-dynamic-components-at-aot-angular-16-1jh0</link>
      <guid>https://dev.to/gupta/i-have-issue-in-creating-dynamic-components-at-aot-angular-16-1jh0</guid>
      <description>&lt;p&gt;I m creating a dynamic component in angular 16 but when i creating a build and running on the server i m geeting &lt;br&gt;
&lt;strong&gt;Can't bind to 'ngIf' since it isn't a known property of 'div' (used in the 'DynamicFetchLocationTemp' component template).&lt;br&gt;
If the 'ngIf' is an Angular control flow directive, please make sure that either the 'NgIf' directive or the 'CommonModule' is a part of an @NgModule where this component is declared.&lt;/strong&gt;  these kind of error. So what i m thinking dynamic components does not read the angular at dynamic way in angular 16 version. Can any body please provide me the way so i can do that. i m using &lt;/p&gt;

&lt;p&gt;createComponentFactory(config: IDynamicCompilerData) {&lt;br&gt;
    let confObj: any = {};&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;confObj[config.template ? 'template' : 'templateUrl'] =
  config.template || config.templateUrl;
confObj[config.css ? 'styles' : 'stylesURL'] =
  [config.css || config.stylesURL];
if(config.animations) {
   confObj['animations'] = config.animations;
}
if(config.encapsulation) {
  confObj['encapsulation'] = config.encapsulation;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
    const tmpCmp = Component(confObj)(config.rootClass);&lt;br&gt;
    const tmpModule = NgModule({&lt;br&gt;
      declarations: [tmpCmp],&lt;br&gt;
      imports: config.imports,&lt;br&gt;
      schemas:[CUSTOM_ELEMENTS_SCHEMA]&lt;br&gt;
    })(class { });&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return this.compiler
  .compileModuleAndAllComponentsAsync(tmpModule)
  .then(factories =&amp;gt; {
    const f = factories.componentFactories.find(
      _ =&amp;gt; _.componentType === config.rootClass
    );
    const cmpRef = config.templateRef.createComponent(f);
    if (config.inputData) {
      for (const val in config.inputData) {
        if (config.inputData[val]) {
          cmpRef.instance[val] = config.inputData[val];
        }
      }
    }
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;this function to create a dynamic component in angular 16.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
