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


TypeScript ViewContainerRef.remove方法代码示例

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


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

示例1: _removeModalElements

  private _removeModalElements() {
    this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._windowCmptRef.hostView));
    if (this._backdropCmptRef) {
      this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._backdropCmptRef.hostView));
    }
    if (this._contentRef && this._contentRef.viewRef) {
      this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._contentRef.viewRef));
    }

    this._windowCmptRef = null;
    this._backdropCmptRef = null;
    this._contentRef = null;
  }
开发者ID:Quinn-L,项目名称:ng-bootstrap,代码行数:13,代码来源:modal-ref.ts

示例2: ngOnChanges

  ngOnChanges() {
    if (this._viewRef) {
      this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
    }

    if (this._templateRef) {
      this._viewRef = this._viewContainerRef.createEmbeddedView(this._templateRef, this._context);
    }
  }
开发者ID:Jake-Church,项目名称:angular,代码行数:9,代码来源:ng_template_outlet.ts

示例3: createView

  private createView() {
    if (isPresent(this._viewRef)) {
      this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
    }

    if (isPresent(this._templateRef)) {
      this._viewRef = this._viewContainerRef.createEmbeddedView(this._templateRef, this._context);
    }
  }
开发者ID:BharatBhatiya,项目名称:test,代码行数:9,代码来源:ng_template_outlet.ts

示例4: ngOnChanges

  ngOnChanges(changes: SimpleChanges) {
    if (this._viewRef) {
      this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
    }

    if (this.ngTemplateOutlet) {
      this._viewRef = this._viewContainerRef.createEmbeddedView(
          this.ngTemplateOutlet, this.ngTemplateOutletContext);
    }
  }
开发者ID:cooperka,项目名称:angular,代码行数:10,代码来源:ng_template_outlet.ts

示例5: ngTemplateOutlet

  @Input()
  set ngTemplateOutlet(templateRef: TemplateRef<Object>) {
    if (isPresent(this._insertedViewRef)) {
      this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._insertedViewRef));
    }

    if (isPresent(templateRef)) {
      this._insertedViewRef = this._viewContainerRef.createEmbeddedView(templateRef);
    }
  }
开发者ID:Coco-wan,项目名称:angular,代码行数:10,代码来源:ng_template_outlet.ts

示例6: active

 @Input() set active(active: boolean) {
     if (this._active == active) {
         return;
     }
     this._active = active;
     if (active) {
         this.viewContainerRef.createEmbeddedView(this.templateRef);
     }
     else {
         this.viewContainerRef.remove(0);
     }
 }
开发者ID:xwLyc,项目名称:learning-angular2,代码行数:12,代码来源:bs-tabs.ts

示例7: reloadComponent

 private reloadComponent() {
    // Remove existing component
    if (this._currentComponent && this.viewContainerRef.length > 0) {
          this.viewContainerRef.remove(0);
    }
    // Add new component
    System.import(this.componentPath)
      .then(m => {
        this.componentResolver.resolveComponent(m[this.componentName]).then((factory: any) => {
          this._currentComponent = this.viewContainerRef.createComponent(factory, 0,  this.viewContainerRef.injector);
          this._currentComponent.instance.initialConfig = this.initialConfig;
        });
      });
 }
开发者ID:remimarenco,项目名称:cloudlaunch-ui,代码行数:14,代码来源:app-placeholder.component.ts

示例8: appRepeat

 @Input() set appRepeat(count: number) {
   if (count > this.viewContainerRef.length) {
     const diff = count - this.viewContainerRef.length;
     for (let i = 0; i < diff; ++i) {
       const repeatContext = new RepeatContext(this.viewContainerRef.length);
       this.viewContainerRef.createEmbeddedView(this.templateRef, repeatContext);
     }
   } else if (count < this.viewContainerRef.length) {
     const diff = this.viewContainerRef.length - count;
     for (let i = 0; i < diff; ++i) {
       this.viewContainerRef.remove(this.viewContainerRef.length - 1);
     }
   }
 }
开发者ID:loki2302,项目名称:html5-experiment,代码行数:14,代码来源:app-repeat.directive.ts

示例9: ngOnChanges

  ngOnChanges(changes: SimpleChanges) {
    if (this.componentRef) {
      this._viewContainerRef.remove(this._viewContainerRef.indexOf(this.componentRef.hostView));
    }
    this._viewContainerRef.clear();
    this.componentRef = null;

    if (this.ngComponentOutlet) {
      let injector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;

      this.componentRef = this._viewContainerRef.createComponent(
          this._cmpFactoryResolver.resolveComponentFactory(this.ngComponentOutlet),
          this._viewContainerRef.length, injector, this.ngComponentOutletContent);
    }
  }
开发者ID:JSMike,项目名称:angular,代码行数:15,代码来源:ng_component_outlet.ts

示例10: constructor

    constructor(containerType: Type<W>, vcr: ViewContainerRef) {
        this.injector = vcr.injector;
        // If the host is already wrapped, we don't do anything
        if (!this.injector.get(containerType, null)) {
            const cfr = this.injector.get(ComponentFactoryResolver);
            const el = this.injector.get(ElementRef);

            // We need a new anchor, since we're projecting the current one.
            vcr.createComponent(cfr.resolveComponentFactory(EmptyAnchor));
            const factory: ComponentFactory<W> = cfr.resolveComponentFactory(containerType);
            // We're assuming only one projection slot, but in more complex cases we might want to provide
            // a different array of projected elements.
            const containerRef = vcr.createComponent(factory, undefined, undefined, [[el.nativeElement]]);
            // We can now remove the useless anchor
            vcr.remove(0);

            // We note that the container was dynamically created
            containerRef.instance._dynamic = true;

            // We keep the wrapper's injector to access the dependencies that weren't available before.
            this.injector = containerRef.injector;
        }
    }
开发者ID:beqom,项目名称:clarity,代码行数:23,代码来源:host-wrapper.ts


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