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


TypeScript angular2.ViewContainerRef類代碼示例

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


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

示例1: bulkInsert

 static bulkInsert(tuples, viewContainer: ViewContainerRef, protoViewRef: ProtoViewRef) {
   tuples.sort((a, b) => a.record.currentIndex - b.record.currentIndex);
   for (var i = 0; i < tuples.length; i++) {
     var tuple = tuples[i];
     if (isPresent(tuple.view)) {
       viewContainer.insert(tuple.view, tuple.record.currentIndex);
     } else {
       tuple.view = viewContainer.create(protoViewRef, tuple.record.currentIndex);
     }
   }
   return tuples;
 }
開發者ID:nil84,項目名稱:GameValue,代碼行數:12,代碼來源:ng_for.ts

示例2: bulkRemove

 static bulkRemove(tuples: List<RecordViewTuple>,
                   viewContainer: ViewContainerRef): List<RecordViewTuple> {
   tuples.sort((a, b) => a.record.previousIndex - b.record.previousIndex);
   var movedTuples = [];
   for (var i = tuples.length - 1; i >= 0; i--) {
     var tuple = tuples[i];
     // separate moved views from removed views.
     if (isPresent(tuple.record.currentIndex)) {
       tuple.view = viewContainer.detach(tuple.record.previousIndex);
       movedTuples.push(tuple);
     } else {
       viewContainer.remove(tuple.record.previousIndex);
     }
   }
   return movedTuples;
 }
開發者ID:cedriclam,項目名稱:angular,代碼行數:16,代碼來源:ng_for.ts

示例3: _applyChanges

  private _applyChanges(changes) {
    if (isBlank(changes)) {
      this.viewContainer.clear();
      return;
    }

    // TODO(rado): check if change detection can produce a change record that is
    // easier to consume than current.
    var recordViewTuples = [];
    changes.forEachRemovedItem((removedRecord) =>
                                   recordViewTuples.push(new RecordViewTuple(removedRecord, null)));

    changes.forEachMovedItem((movedRecord) =>
                                 recordViewTuples.push(new RecordViewTuple(movedRecord, null)));

    var insertTuples = NgFor.bulkRemove(recordViewTuples, this.viewContainer);

    changes.forEachAddedItem((addedRecord) =>
                                 insertTuples.push(new RecordViewTuple(addedRecord, null)));

    NgFor.bulkInsert(insertTuples, this.viewContainer, this.protoViewRef);

    for (var i = 0; i < insertTuples.length; i++) {
      this._perViewChange(insertTuples[i].view, insertTuples[i].record);
    }
  }
開發者ID:cedriclam,項目名稱:angular,代碼行數:26,代碼來源:ng_for.ts

示例4: localVariable

  set localVariable(exp) {
    if (!this.viewContainer.length) {
      this.view = this.viewContainer.create(this.protoViewRef);
    }

    this.view.setLocal("$implicit", exp);
  }
開發者ID:B-Thapa,項目名稱:angular,代碼行數:7,代碼來源:assign_local_directive.ts


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