本文整理汇总了TypeScript中@angular/core.IterableDiffer类的典型用法代码示例。如果您正苦于以下问题:TypeScript IterableDiffer类的具体用法?TypeScript IterableDiffer怎么用?TypeScript IterableDiffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IterableDiffer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: ngDoCheck
// ngDoCheck is called every time the component is checked, which is quite a lot as it's checked on every event
ngDoCheck(): void {
const changes = this.differ.diff(this.comments);
if (changes) {
console.log('%cIterableDiffers', 'color:orange', changes);
changes.forEachAddedItem(r =>
console.log('%cAdded', 'color:orange', r.item)
);
changes.forEachRemovedItem(r =>
console.log('%cRemoved', 'color:orange', r.item)
);
}
}
开发者ID:screenm0nkey,项目名称:angular2-examples-webpack,代码行数:13,代码来源:lifecycle_03.ts
示例2: updateLayers
/**
* Update the state of the layers.
* We use an iterable differ to synchronize the map layers with the state of the bound layers array.
* This is important because it allows us to react to changes to the contents of the array as well
* as changes to the actual array instance.
*/
private updateLayers() {
const map = this.leafletDirective.getMap();
if (null != map && null != this.layersDiffer) {
const changes = this.layersDiffer.diff(this.layersValue);
if (null != changes) {
// Run outside angular to ensure layer events don't trigger change detection
this.zone.runOutsideAngular(() => {
changes.forEachRemovedItem((c) => {
map.removeLayer(c.item);
});
changes.forEachAddedItem((c) => {
map.addLayer(c.item);
});
});
}
}
}
开发者ID:misteronak,项目名称:Verion-1.0-Donation-Dashboard,代码行数:32,代码来源:leaflet-layers.directive.ts
示例3: _clear
/** Clear the children dataNodes. */
protected _clear(): void {
const outlet = this._getNodeOutlet();
if (outlet) {
outlet.viewContainer.clear();
this._dataDiffer.diff([]);
}
}
开发者ID:Nodarii,项目名称:material2,代码行数:8,代码来源:nested-node.ts
示例4: updateChildrenNodes
/** Add children dataNodes to the NodeOutlet */
protected updateChildrenNodes(): void {
if (this.nodeOutlet.length && this._children) {
const viewContainer = this.nodeOutlet.first.viewContainer;
this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data);
} else {
// Reset the data differ if there's no children nodes displayed
this._dataDiffer.diff([]);
}
}
开发者ID:davidgabrichidze,项目名称:material2,代码行数:10,代码来源:nested-node.ts
示例5: ngOnChanges
ngOnChanges(changes: SimpleChanges): void {
// Create a new columns differ if one does not yet exist. Initialize it based on initial value
// of the columns property.
const columns = changes['columns'].currentValue;
if (!this._columnsDiffer && columns) {
this._columnsDiffer = this._differs.find(columns).create();
this._columnsDiffer.diff(columns);
}
}
开发者ID:HemanthKona,项目名称:material2,代码行数:9,代码来源:row.ts
示例6: ngOnChanges
ngOnChanges(changes: SimpleChanges): void {
// Create a new columns differ if one does not yet exist. Initialize it based on initial value
// of the columns property or an empty array if none is provided.
if (!this._columnsDiffer) {
const columns = (changes['columns'] && changes['columns'].currentValue) || [];
this._columnsDiffer = this._differs.find(columns).create();
this._columnsDiffer.diff(columns);
}
}
开发者ID:jwren,项目名称:intellij-plugins,代码行数:9,代码来源:cdk_row.ts
示例7:
ngDoCheck() {
console.log('do check called');
if (this.differ) {
const changes = this.differ.diff(this.items);
console.dir(changes);
}
}
开发者ID:training4developers,项目名称:ng2prep,代码行数:10,代码来源:demo.ts
示例8: ngDoCheck
ngDoCheck() {
if (this._differ) {
const changes = this._differ.diff(this._rawItems);
if (changes) {
// TODO: not very efficient right now,
// but premature optimization is the root of all evil.
this._items.all = this._rawItems;
}
}
}
开发者ID:beqom,项目名称:clarity,代码行数:10,代码来源:datagrid-items.ts
示例9: ngDoCheck
ngDoCheck(): void {
if (!this.differ) {
return;
}
const changes = this.differ.diff(this.easyListForOf);
if (changes) {
this.applyChanges(changes);
}
}
开发者ID:rimlin,项目名称:ng-easy-list,代码行数:11,代码来源:easy-list-for.directive.ts
示例10: updateChildrenNodes
/** Add children dataNodes to the NodeOutlet */
protected updateChildrenNodes(children?: T[]): void {
const outlet = this._getNodeOutlet();
if (children) {
this._children = children;
}
if (outlet && this._children) {
const viewContainer = outlet.viewContainer;
this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data);
} else {
// Reset the data differ if there's no children nodes displayed
this._dataDiffer.diff([]);
}
}
开发者ID:Nodarii,项目名称:material2,代码行数:14,代码来源:nested-node.ts
注:本文中的@angular/core.IterableDiffer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论