當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。