title: How to check if components already exists in viewContainerRef Angular
body: <p>Im adding components dynamically like this:</p>
  
  <pre><code>export class CustomersOverviewComponent implements OnInit, OnDestroy {
  
    @ViewChild(PanelDirective) customerHost: PanelDirective;
  
    constructor(private componentFactoryResolver: ComponentFactoryResolver, private sidebarService: SidebarService) {
  
    }
  
    ngOnDestroy(): void {
  
    }
  
    ngOnInit(): void {
      console.log('init');
  
      this.sidebarService.currentAddPanel.subscribe(panel =&gt; {
        if (panel instanceof PanelItem) {
          this.loadcomponent(panel);
        }
      });
    }
  
    loadcomponent(panel: PanelItem): void {
      let componentFactory = this.componentFactoryResolver.resolveComponentFactory(panel.component);
      let viewContainerRef = this.customerHost.viewContainerRef;
  
      console.log('viewcontainer', viewContainerRef);
      console.log('element', viewContainerRef.element);
  
      let componentRef = viewContainerRef.createComponent(componentFactory);
  
      (&lt;IPanel&gt;componentRef.instance).data = panel.data;
      (&lt;IPanel&gt;componentRef.instance).self = componentRef;
    }
  
  
  }
  </code></pre>
  
  <p>But before adding a new component to the viewContainer i wanna loop though it and check if my component already exists or not. How can i do this?</p>
  
  <p>I cant see any loop-able properties in viewContainerRef.</p>