変更検出ストラテジーがonPushに設定されている場合、コンポーネント属性が変更された場合、コンポーネントのみを再レンダリングする必要があります。ここでng.core.ChangeDetectionStrategy.onPushはどのように機能しますか?
はサンプルコードです:ここで
var SampleComponent1 = ng.core.Component({
selector: "sampleone",
template: "{{value}}",
viewProviders: [ng.core.ChangeDetectorRef],
changeDetection: ng.core.ChangeDetectionStrategy.onPush
}).Class({
constructor: [ng.core.ChangeDetectorRef, function(cd){
this.cd = cd;
}],
ngOnInit: function(){
this.value = 1;
setInterval(function(){
this.value++;
}.bind(this), 2000)
}
})
var App = ng.core.Component({
selector: "app",
directives: [SampleComponent1],
template: "<sampleone ></sampleone>"
}).Class({
constructor: function(){
}
})
属性はテンプレートがレンダリングされて変化していない場合でも?これはバグですか、私はプッシュで誤解しましたか?