This plunker should make it very clear what the scenario and issue is...
https://plnkr.co/edit/OJEoafoPZpz8gaxEbTBb?p=preview
The app.ts
parent component has an array of objects s2data
which is passed to the Data
Input() of the dropdown.component.ts
child component.
<app-dropdown [Data]="s2data"></app-dropdown>
When the app component button is clicked, an new object is pushed to the s2data
array.
onClick() {
this.s2data.push({
id: '6',
text: 'six'
});
}
The JSON strings correctly show that the s2data
array has been updated.
However, even though the dropdown component Input() has changed, the ngOnChanges event does not seem to be getting triggered, which is reflected by the unchanged count of ngOnChangeEventCount
.
So my question is... why is ngOnChanges
not happening in the child component, even though the input has clearly been changed.