создается. В первом диве. 
                  
                  
                  
                  
                  
                  <div *ngFor="let field of item.fields" >
                  
                  
                     <ng-template pf-host ></ng-template>
                  
                  
                  </div>
                  
                  
                  
                  
                  
                  loadComponent() {
                  
                  
                      this.item.fields.forEach(item => {
                  
                  
                          const componentFactory = this.componentFactoryResolver.resolveComponentFactory(component);
                  
                  
                          const viewContainerRef = this.pfHost.viewContainerRef;
                  
                  
                          const componentRef = viewContainerRef.createComponent(componentFactory);
                  
                  
                           });
                  
                  
                  }
                  
                  
                  
                  
                  
                  Как поправить? Оба цикла по одному и тому же массиву идут. Хочется чтобы в 1 диве был первый компонент, во втором второй и так далее
                  
                  
                
Что такое this.pfHost? ViewChild? Скорее всего нужно использовать ViewChildren и по индексу рисовать
Вы не рассматривали возможность использовать готовые решения для работы с динамическими компонентами? https://github.com/IndigoSoft/ngxd/tree/development
Обсуждают сегодня