本文整理匯總了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;
}
示例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;
}
示例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);
}
}
示例4: localVariable
set localVariable(exp) {
if (!this.viewContainer.length) {
this.view = this.viewContainer.create(this.protoViewRef);
}
this.view.setLocal("$implicit", exp);
}