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


TypeScript core.EmbeddedViewRef類代碼示例

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


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

示例1: setAttributes

 setAttributes(attrs: WormholeAttributes) {
   this.cachedAttrs = attrs;
   if (this.viewRef && attrs && typeof attrs === 'object') {
     Object.assign(this.viewRef.context, attrs);
     this.viewRef.markForCheck();
   }
 }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:7,代碼來源:wormhole-base.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: connect

  connect(attrs?: WormholeAttributes, events?: string[], index?: number): Observable<WormholeEvent> {
    if (typeof attrs === 'object' && attrs) {
      this.cachedAttrs = attrs;
    }

    this.disconnect();
    this.viewRef = this.attach(this.templateRef, index);

    this.viewRef.onDestroy(() => {
      this.viewRef = undefined;
    });

    if (this.cachedAttrs && typeof this.cachedAttrs === 'object') {
      Object.assign(this.viewRef.context, this.cachedAttrs);
    }
    this.viewRef.detectChanges();
    return NEVER;
  }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:18,代碼來源:wormhole-base.ts

示例4: ngOnChanges

	// ---
	// PUBLIC METHODS.
	// ---

	// I get called when any of the input bindings are updated.
	public ngOnChanges( changes: SimpleChanges ) : void {

		// NOTE: Since this Directive uses an ATTRIBUTE-BASED SELECTOR, we know that the
		// ngOnChanges() life-cycle method will be called AT LEAST ONCE. As such, we can
		// be confident that the embedded view will be marked for changes at least once.
		// --
		// We also want to check the view for changes any time the input-binding is
		// changed. This gives the calling context a chance to drive changes based on a
		// single expression even when change-detection is limited.
		this.embeddedViewRef.detectChanges();

	}
開發者ID:bennadel,項目名稱:JavaScript-Demos,代碼行數:17,代碼來源:bind-once.directive.ts

示例5:

	// I initialize the bind-once directive.
	constructor(
		templateRef: TemplateRef<void>,
		viewContainerRef: ViewContainerRef
		) {

		this.embeddedViewRef = viewContainerRef.createEmbeddedView( templateRef );
		// Since we want manual control over when the content of the view is checked,
		// let's immediately detach the view. This removes it from the change-detection
		// tree. Now, it will only be checked when we either re-attach it to the change-
		// detection tree or we explicitly call .detectChanges() (see ngOnChanges()).
		this.embeddedViewRef.detach();

	}
開發者ID:bennadel,項目名稱:JavaScript-Demos,代碼行數:14,代碼來源:bind-once.directive.ts

示例6: ngOnChanges

  ngOnChanges(changes: { [key: string]: SimpleChange }) {
    if (changes['templateWrapper']) {
      if (this.embeddedViewRef) {
        this.embeddedViewRef.destroy();
      }

      this.embeddedViewRef = this.viewContainer.createEmbeddedView(
        this.templateWrapper, {
          value: this.value,
          row: this.row,
          column: this.column
        });
    }

    if (this.embeddedViewRef) {
      this.embeddedViewRef.context.value = this.value;
      this.embeddedViewRef.context.row = this.row;
      this.embeddedViewRef.context.column = this.column;
    }
  }
開發者ID:Alber70g,項目名稱:angular2-data-table,代碼行數:20,代碼來源:TemplateWrapper.ts

示例7: ngOnDestroy

    ngOnDestroy() {
		this.view.destroy();
	}
開發者ID:SebaPucheta,項目名稱:angular2-multiselect-dropdown,代碼行數:3,代碼來源:menu-item.ts


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