本文整理汇总了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;未经允许,请勿转载。 |
请发表评论