當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ViewContainerRef.createComponent方法代碼示例

本文整理匯總了TypeScript中@angular/core.ViewContainerRef.createComponent方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ViewContainerRef.createComponent方法的具體用法?TypeScript ViewContainerRef.createComponent怎麽用?TypeScript ViewContainerRef.createComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/core.ViewContainerRef的用法示例。


在下文中一共展示了ViewContainerRef.createComponent方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: ngAfterContentInit

 ngAfterContentInit() {
   const authFormFactory = this.resolver.resolveComponentFactory(AuthFormComponent);
   this.entry.createComponent(authFormFactory);
   this.component = this.entry.createComponent(authFormFactory, 0);
   this.component.instance.title = 'Create account';
   this.component.instance.submitted.subscribe(this.loginUser);
 }
開發者ID:donroyco,項目名稱:angular-pro-src,代碼行數:7,代碼來源:app.component.ts

示例2: ifLoader

  @Input() set ifLoader(loading: boolean) {
    console.log('ifLoader, loading : ', loading);

    if (loading) {
      // create and attach a loader to our viewContainer
      const factory = this.cfResolver.resolveComponentFactory(LoaderSpinnerComponent);
      this.loaderComponentRef = this.viewContainer.createComponent(factory);

      // remove any embedded view
      if (this.embeddedViewRef) {
        this.embeddedViewRef.destroy();
        this.embeddedViewRef = null;
      }
    } else {

      // remove any loader
      if (this.loaderComponentRef) {
        this.loaderComponentRef.destroy();
        this.loaderComponentRef = null;
      }

      // create and attach our embeddedView
      this.embeddedViewRef = this.viewContainer.createEmbeddedView(this.templateRef);
    }
  }
開發者ID:guillaumeLeRoy,項目名稱:eritis_fe,代碼行數:25,代碼來源:if.directive.ts

示例3: loadComponent

 loadComponent() {
   this.entry.clear();
   const className = this.getComponentName(this.contact.type);
   const componentFactory = this.componentFactoryResolver.resolveComponentFactory(contacts[className]);
   this.componentRef = this.entry.createComponent(componentFactory, this.entry.length, null);
   (this.componentRef.instance).contact = this.contact;
 }
開發者ID:meumobi,項目名稱:infomobi,代碼行數:7,代碼來源:contact-details.ts

示例4: ionViewPreLoad

  ionViewPreLoad() {
    const component = this._navParams.data.component;
    if (!component) {
      console.warn('modal\'s page was not defined');
      return;
    }

    let cfr = this.moduleLoader.getComponentFactoryResolver(component);
    if (!cfr) {
      cfr = this._cfr;
    }
    const componentFactory = cfr.resolveComponentFactory(component);

    // ******** DOM WRITE ****************
    const componentRef = this._viewport.createComponent(componentFactory, this._viewport.length, this._viewport.parentInjector, []);

    this._setCssClass(componentRef, 'ion-page');
    this._setCssClass(componentRef, 'show-page');

    // Change the viewcontroller's instance to point the user provided page
    // Lifecycle events will be sent to the new instance, instead of the modal's component
    // we need to manually subscribe to them
    this._viewCtrl._setInstance(componentRef.instance);
    this._viewCtrl.willEnter.subscribe(this._viewWillEnter.bind(this));
    this._viewCtrl.didLeave.subscribe(this._viewDidLeave.bind(this));

    this._enabled = true;
  }
開發者ID:HugoHeneault,項目名稱:ionic,代碼行數:28,代碼來源:modal-component.ts

示例5:

 this.api.getProfile().subscribe((data: any)=>{
   console.log(data)
   if(data.signedOut){
     const factory = this.resolver.resolveComponentFactory(SignupComponent)
     this.componentRef = this.entry.createComponent(factory)
   } else{
     if(data.username == null){
       const factory = this.resolver.resolveComponentFactory(CreateusernameComponent)
       this.componentRef = this.entry.createComponent(factory)
     } else{
       this.api.changeUserData(data)
       const factory = this.resolver.resolveComponentFactory(HomePageComponent)
       this.componentRef = this.entry.createComponent(factory)
     }
   }
 })
開發者ID:rlopez1j,項目名稱:FoodHat,代碼行數:16,代碼來源:home.component.ts

示例6: start

    public start(viewContainerRef: ViewContainerRef) {           
        let spinnerRef: any;

        const factory = this.resolver.resolveComponentFactory(SpinnerComponent);

        if (viewContainerRef) {
            spinnerRef = viewContainerRef.createComponent(factory);
            //spinnerRef = this.componentLoader.loadNextToLocation(SpinnerComponent, viewContainerRef);
        }
        else {
            spinnerRef = this._viewContainerRef.createComponent(factory);
            //spinnerRef = this.componentLoader.loadNextToLocation(SpinnerComponent, this._viewContainerRef);
        }

        return spinnerRef;
    }
開發者ID:antonsirocka,項目名稱:angular2-moviedb,代碼行數:16,代碼來源:spinner-service.ts

示例7: buildControl

  private buildControl(controlConfig: ControlConfig): void {
    const factory = this.cfr.resolveComponentFactory(DynamicControlComponent);
    const control = this.formContainer.createComponent(factory);

    control.instance.controlConfig = controlConfig;
    control.instance.formGroup = this.form;
  }
開發者ID:niralmunjariya,項目名稱:angular-dynamic-forms,代碼行數:7,代碼來源:form-renderer.component.ts

示例8: open

  public open(modalInstance: SkyModalInstance, component: any, providers?: any[]) {
    let factory = this.resolver.resolveComponentFactory(component);
    let hostService = new SkyModalHostService();

    providers = providers || [];

    providers.push({
      provide: SkyModalHostService,
      useValue: hostService
    });

    let resolvedProviders = ReflectiveInjector.resolve(providers);

    let injector = ReflectiveInjector.fromResolvedProviders(resolvedProviders, this.injector);

    let modalComponentRef = this.target.createComponent(factory, undefined, injector);

    modalInstance.componentInstance = modalComponentRef.instance;

    function closeModal() {
      hostService.destroy();
      modalComponentRef.destroy();
    }

    hostService.close.subscribe((modalComponent: SkyModalComponent) => {
      closeModal();
    });

    modalInstance.setCloseCallback(() => {
      closeModal();
    });
  }
開發者ID:blackbaud-brandonstirnaman,項目名稱:skyux2,代碼行數:32,代碼來源:modal-host.component.ts

示例9: ngOnInit

    public ngOnInit() {
        // dynamic template built (TODO driven by some incoming settings)        

        // now we get built component, just to load it
        let dynamicComponent = this.customComponentBuilder
            .CreateComponent(this.template);

        // we have a component and its target
        let factory = this.componentResolver
            .resolveComponentFactory<IHaveDynamicData>(dynamicComponent);

        // console.log('creating compoent with template: ' + this.template);

        // Instantiates a single {@link Component} and inserts its Host View 
        //   into this container at the specified `index`
        let comp = this.dynamicComponentTarget.createComponent(factory, 0);

        // and here we have access to our dynamic component
        this.component = comp.instance;
        this.previousTemplate = this.template;

        this.component.title = this.title;
        this.component.entity = this.entity;

    }
開發者ID:orizzonte,項目名稱:digi-map,代碼行數:25,代碼來源:dynamic.component.holder.ts

示例10: new

 public createComponent<T>(componentType: { new(...args: any[]): T; }): ComponentRef<T> {
     // used to cache the factory, but this a) caused issues when used with either webpack/angularcli with --prod
     // but more significantly, the underlying implementation of resolveComponentFactory uses a map too, so us
     // caching the factory here yields no performance benefits
     let factory = this.componentFactoryResolver.resolveComponentFactory(componentType);
     return this.viewContainerRef.createComponent(factory);
 }
開發者ID:Hyeong-jin,項目名稱:ag-grid,代碼行數:7,代碼來源:ng2FrameworkComponentWrapper.ts


注:本文中的@angular/core.ViewContainerRef.createComponent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。