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


TypeScript linker.ViewContainerRef类代码示例

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


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

示例1: _bulkInsert

 private _bulkInsert(tuples: RecordViewTuple[]): RecordViewTuple[] {
   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)) {
       this._viewContainer.insert(tuple.view, tuple.record.currentIndex);
     } else {
       tuple.view =
           this._viewContainer.createEmbeddedView(this._templateRef, tuple.record.currentIndex);
     }
   }
   return tuples;
 }
开发者ID:MingXingTeam,项目名称:awesome-front-end,代码行数:13,代码来源:ng_for.ts

示例2: _bulkRemove

 private _bulkRemove(tuples: RecordViewTuple[]): 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 = this._viewContainer.detach(tuple.record.previousIndex);
       movedTuples.push(tuple);
     } else {
       this._viewContainer.remove(tuple.record.previousIndex);
     }
   }
   return movedTuples;
 }
开发者ID:MingXingTeam,项目名称:awesome-front-end,代码行数:15,代码来源:ng_for.ts

示例3: _applyChanges

  private _applyChanges(changes) {
    // 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 = this._bulkRemove(recordViewTuples);

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

    this._bulkInsert(insertTuples);

    for (var i = 0; i < insertTuples.length; i++) {
      this._perViewChange(insertTuples[i].view, insertTuples[i].record);
    }

    for (var i = 0, ilen = this._viewContainer.length; i < ilen; i++) {
      this._viewContainer.get(i).setLocal('last', i === ilen - 1);
    }
  }
开发者ID:MingXingTeam,项目名称:awesome-front-end,代码行数:25,代码来源:ng_for.ts


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