/** * created by Menna */ import { ComponentFactoryResolver, ViewContainerRef, ComponentRef } from '@angular/core'; import { LocalizedComponent } from '../localized-component/localized-component'; import { ViewLocalizedComponent } from '../view-localized-component/view-localized-component'; export class LocalizedStringFactory { constructor(private componentFactoryResolver: ComponentFactoryResolver) { } createLocalizedCmp(containerRef: ViewContainerRef, lang: any, removeCallback: Function, idDiv: string, modelInput: any): ComponentRef { let factory = this.componentFactoryResolver.resolveComponentFactory(LocalizedComponent); let cmpRef = containerRef.createComponent(factory); if (lang) { cmpRef.instance.lang = lang; cmpRef.instance.removeCallback = removeCallback; cmpRef.instance.idDiv = idDiv; cmpRef.instance.modelInput = modelInput; } return cmpRef; } createViewLocalizedCmp(containerRef: ViewContainerRef, model: any, fieldName: string, Label_fieldName: string): ComponentRef { let factory = this.componentFactoryResolver.resolveComponentFactory(ViewLocalizedComponent); let cmpRef = containerRef.createComponent(factory); let instance: ViewLocalizedComponent = cmpRef.instance; instance.options = model; instance.fieldName = fieldName; instance.Label_fieldName = Label_fieldName; return cmpRef; } }