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


TypeScript core.IterableDiffer類代碼示例

本文整理匯總了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;未經允許,請勿轉載。