我面临问题ngChanges
没有检测到一个属性更改而不是另一个属性更改,如注释中所突出显示的那样。在ngchanges
中检测到对象更改,但ngchanges
未检测到属性值更改。
为什么会发生这种情况以及如何解决
父组件ts
this.route.data
.subscribe(cdata => {
cdata.data[0].subscribe(sRow => {
this.success = sRow;
});
cdata.data[1].subscribe(allRows => {
const fullCount = Number(allRows.filter(Row => Row.ErrorCode === 0).length);
this.successCount = fullCount;
});
});
}
<gss-gridview [ListSource]="success" [PageSize]="5" (TotalItemCount)="successCount"
(prevBtn)="prevPage($event)" (nextBtn)="nextPage($event)"
(approveBtn)="approve($event)" (rejectBtn)="reject($event)" (sort)="sortList($event)"
(filterInput)="filterList($event)" >
</gss-gridview>
儿童组件ts
ngOnChanges(changes: SimpleChanges) {
const updated: SimpleChange = changes.ListSource;
const updatedItemCount: SimpleChange = changes.TotalItemCount; // this comes as undefined
if (updated) {
this.success = updated.currentValue; // this is working
}
if (updatedItemCount) {
this.successCount = updatedItemCount.currentValue;// not working as results are undefined
}
}
@Input() ListSource: Array<Metric>;
@Input() PageSize: number;
@Input() BatchSize: number;
@Input() TotalItemCount: number;