当前位置: 首页>>代码示例>>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;未经允许,请勿转载。