It seemed to me that I understood quite clearly how the Angular change detection function works after this discussion: Why doesn't change detection happen here when [value] is changed?
But look at this plunge: https://plnkr.co/edit/jb2k7U3TfV7qX2x1fV4X?p=preview
@Component({ selector: 'simple', template: ` <div (click)="onClick()"> {{myData[0].name}} </div> `, changeDetection: ChangeDetectionStrategy.OnPush }) export class Simple { public @Input() myData; constructor() { } public onClick() { } }
Press a, it changed to c
I understand that the click event triggers application-level change detection, but [myData] = "testData" still refers to the same object, and I use On Push on Simple, why has it changed?
angular
techguy2000 Feb 18 '17 at 6:49 2017-02-18 06:49
source share