import { ComponentRef , ComponentFactory , ComponentFactoryResolver , Injector , ViewContainerRef } from '@angular/core' ; export interface CreateComponentArgs { component : any ; vcRef : ViewContainerRef ; injector ? : Injector ; projectableNodes ? : any [ ] [ ] ; } export function createComponent ( instructions ) { const injector = instructions . injector || instructions . vcRef . parentInjector ; const cmpFactory = injector . get ( ComponentFactoryResolver ) . resolveComponentFactory ( instructions . component ) ; if ( instructions . vcRef ) { return instructions . vcRef . createComponent ( cmpFactory , instructions . vcRef . length , injector , instructions . projectableNodes ) ; } else { return cmpFactory . create ( injector ) ; } }