当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript core.ViewContainerRef类代码示例

本文整理汇总了TypeScript中@angular/core.ViewContainerRef的典型用法代码示例。如果您正苦于以下问题:TypeScript ViewContainerRef类的具体用法?TypeScript ViewContainerRef怎么用?TypeScript ViewContainerRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ViewContainerRef类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

  /**
   * Creates an instance of a Component and attaches it to the View Container found at the
   * `location` specified as {@link ViewContainerRef}.
   *
   * You can optionally provide `providers` to configure the {@link Injector} provisioned for this
   * Component Instance.
   *
   * Returns {@link ComponentRef} representing the newly created Component.
   * @param ComponentClass - @Component class
   * @param location - reference to the location
   * @param providers - optional array of providers
   * @returns {ComponentRef<T>} - returns ComponentRef<T>
   */
  public appendNextToLocation<T>(ComponentClass:Type<T>,
                                 location:ViewContainerRef,
                                 providers?:ResolvedReflectiveProvider[]):ComponentRef<T> {
    let componentFactory = this.componentFactoryResolver.resolveComponentFactory(ComponentClass);
    let parentInjector = location.parentInjector;
    let childInjector: Injector = parentInjector;
    if (providers && providers.length > 0) {
      childInjector = ReflectiveInjector.fromResolvedProviders(providers, parentInjector);
    }

    return location.createComponent(componentFactory, location.length, childInjector);
  }
开发者ID:jdelgadoalfonso,项目名称:ng2-bootstrap,代码行数:25,代码来源:components-helper.service.ts

示例2: createComponent

export function createComponent(cfr: ComponentFactoryResolver,
                                        type: any,
                                        vcr: ViewContainerRef,
                                        bindings: ResolvedReflectiveProvider[],
                                        projectableNodes?: any[][]): ComponentRef<any> {
  return vcr.createComponent(
    cfr.resolveComponentFactory(type),
    vcr.length,
    getInjector(vcr, bindings),
    projectableNodes
  );
}
开发者ID:CaselIT,项目名称:angular2-modal,代码行数:12,代码来源:createComponent.ts

示例3:

 this._pageService.get_page_by_survey(this.current_survey.survey_id).subscribe(data=>{
   this.lstPage = data.Data;
   this.current_page = this.lstPage.filter(x=>x.page_id == page_id)[0];
   this.questionContainer.clear();
   this.loadByPage();
   if(data.TotalRows%2 ==0){
     $(".pagings").css("background-color","#0683c9")
   }else{
     $(".pagings").css("background-color","#85d2fc")
   }
 });
开发者ID:luuthi,项目名称:mysurvey,代码行数:11,代码来源:report.component.ts

示例4: done

      this._resolver.resolveComponent(page).then(factory => {
        const pageComponentRef = this._viewContainer.createComponent(factory, 0, injector);
        const pageElement = pageComponentRef.location.nativeElement;

        this.element.appendChild(pageElement); // dirty fix to insert in correct position

        done({
          element: pageElement,
          unload: () => pageComponentRef.destroy()
        });
      });
开发者ID:DavyDuDu,项目名称:OnsenUI,代码行数:11,代码来源:ons-splitter.ts

示例5: attachTemplatePortal

  /**
   * Attach the given TemplatePortal to this PortlHost as an embedded View.
   * @param portal Portal to be attached.
   */
  attachTemplatePortal(portal: TemplatePortal): Map<string, any> {
    portal.setAttachedHost(this);

    this._viewContainerRef.createEmbeddedView(portal.templateRef);
    super.setDisposeFn(() => this._viewContainerRef.clear());

    this._portal = portal;

    // TODO(jelbourn): return locals from view
    return new Map<string, any>();
  }
开发者ID:attilacsanyi,项目名称:material2,代码行数:15,代码来源:portal-directives.ts

示例6:

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

                // and here we have access to our dynamic component
                let component: IHaveDynamicData = dynamicComponent.instance;

                component.name = "The name passed to component as a value";
                component.entity = this.entity;
            });
开发者ID:DavyDuDu,项目名称:ng2Boilerplate,代码行数:11,代码来源:dynamic.component.holder.ts

示例7:

      .then(factory => {
        // Create Injector for Component
        const injector = ReflectiveInjector.fromResolvedProviders([], this.vcRef.parentInjector);

        // Create Component with factory and injector. 0 = index which determines where in the
        // container the component will be rendered. 0 means it will be rendered starting at the
        // beginning
        const componentRef = this.vcRef.createComponent(factory, 0, injector, []);

        // Define any parameters you want to pass to the newly generated component
        componentRef.instance.item = this.item;
      });
开发者ID:jmcclanahan,项目名称:dynamic-component-generator,代码行数:12,代码来源:dynamicHtmlOutlet.directive.ts

示例8: Error

 ngOnInit() {
   if (!components[this.config.type]) {
     const supportedTypes = Object.keys(components).join(', ');
     throw new Error(`Trying to use an unsupported type (${this.config.type}).
       Supported types: ${supportedTypes}`);
   }
   const component = this.resolver.resolveComponentFactory<Field>(components[this.config.type]);
   this.component = this.container.createComponent(component);
   this.component.instance.config = this.config;
   this.component.instance.group = this.group;
   this.component.instance.fieldShow = this.fieldShow;
 }
开发者ID:joshr4,项目名称:webui,代码行数:12,代码来源:dynamic-field.directive.ts

示例9:

  _update() {
    if (this._currentValue) {
      if (!this._viewRef) {
        this._viewContainerRef.clear();
        this._elseViewRef = void 0;

        if (this._templateRef) {
          this._viewRef = this._viewContainerRef.createEmbeddedView(this._templateRef);
        }
      }
    } else {
      if (!this._elseViewRef) {
        this._viewContainerRef.clear();
        this._viewRef = void 0;

        if (this._elseTemplateRef) {
          this._elseViewRef = this._viewContainerRef.createEmbeddedView(this._elseTemplateRef);
        }
      }
    }
  }
开发者ID:iamthelogik83,项目名称:front,代码行数:21,代码来源:if-feature.directive.ts

示例10: loadInLocation

    private loadInLocation(componentType: Type<any>): Promise<ComponentRef<any>> {
        const factory = this.resolver.resolveComponentFactory(componentType);
        const componentRef = this.containerRef.createComponent(
            factory, this.containerRef.length, this.containerRef.parentInjector);

        // Component is created, built may not be checked if we are loading
        // inside component with OnPush CD strategy. Mark us for check to be sure CD will reach us.
        // We are inside a promise here so no need for setTimeout - CD should trigger
        // after the promise.
        log("DetachedLoader.loadInLocation component loaded -> markForCheck");

        return Promise.resolve(componentRef);
    }
开发者ID:NathanWalker,项目名称:nativescript-angular,代码行数:13,代码来源:detached-loader.ts


注:本文中的@angular/core.ViewContainerRef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。