Angular Dynamic Components - Add Class and other attributes : <p>I am using the following code for creating the dynamic components</p>

<pre><code>import {
  Component, OnInit, ViewContainerRef, ViewChild, ViewChildren,
  ReflectiveInjector, ComponentFactoryResolver, ViewEncapsulation, QueryList, Input, AfterViewInit
} from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { forEach } from '@angular/router/src/utils/collection';
import { IComponent } from 'app/app.icomponent';


@Component({
  encapsulation: ViewEncapsulation.None,
  selector: 'dynamic-component',
  entryComponents: [HomeComponent, HighlevelSignalComponent],
  template: `
    &lt;div #dynamicDiv [ngClass]="classFromMenu" &gt;
     &lt;ng-template #dynamicComponentContainer&gt;&lt;/ng-template&gt;
    &lt;/div&gt;
  `,
  styleUrls: [
    './dynamic-content.component.css'
  ],
})

export class DynamicComponent implements IComponent, OnInit, AfterViewInit {
  classFromMenu: any;
 @ViewChild('dynamicComponentContainer', { read: ViewContainerRef }) dynamicComponentContainer: ViewContainerRef;


  constructor(private resolver: ComponentFactoryResolver, private route: Router,
    private activatedRoute: ActivatedRoute, ) {

  }

  .......

  buildComponent(passedData) {
   // orderAndObjs has the data for creating the component

      this.orderAndObjs.forEach(obj =&gt; {
        var componentFactory = this.resolver.resolveComponentFactory(obj.component);
        var compRef = this.dynamicComponentContainer.createComponent(componentFactory);


     // compRef is the component that is created.
//Assuming the component that i am trying to create is &lt;dynamic-component&gt;. 


  //I want to add either a class or any other attribute like this
//&lt;dynamic-component class="flex"&gt;
      });

    }
  }

}
</code></pre>

<p>The dynamic-component is created perfectly fine and everything is working as expected. But the only issue is I want to add a class for dynamic-component so that it can be </p>

<pre><code>&lt;dynamic-component class="dynamicClass"&gt;
</code></pre>

<p>Any help is appreciated :( </p>
