ChangeDetectionStrategy

このエントリーをはてなブックマークに追加

ChangeDetectionStrategyはモデルの変更を検知しUIに反映する際の設定です。

Angularは通常、非同期処理の後にChange Detectionを実行するが、ComponentのchangeDetectionに対してChangeDetectionStrategy.OnPushを指定することでその設定をOFFにして手動によるモデルの変更でのみChange Detectionを実行するように変更します。

@Component({
  selector: "body",
  changeDetection:ChangeDetectionStrategy.OnPush,
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

デフォルトはChangeDetectionStrategy.defaultが指定されており、この場合はあらゆる非同期処理の後にChange Detectionが実行されます。

参考URL

ChangeDetectionStrategy enum - Angular

登録日 : 2017年01月28日 最終更新日 : 2017年1月28日

同じカテゴリー(@angular/core)のエントリー

検索

スポンサードリンク

バージョン

リファレンス