The parent component's parameter changed with Array.push () does not call ngOnChanges on the child component that accepts it as input ()

This plunker should clearly state what the scenario is and the problem ...

https://plnkr.co/edit/OJEoafoPZpz8gaxEbTBb?p=preview

The parent component app.ts

has an array of objects s2data

that is passed to the Data

Input () of the child component dropdown.component.ts

.

<app-dropdown [Data]="s2data"></app-dropdown>

      

When an application component button is clicked, the new array will be moved to the array s2data

.

onClick() {
  this.s2data.push({
    id: '6',
    text: 'six'
  });
}

      

The JSON lines correctly show that the array has been s2data

updated.

However, even though the Input () dropdown has changed, the ngOnChanges event does not seem to fire, which is reflected by the unchanged counter ngOnChangeEventCount

.

So my question is why is ngOnChanges

n't happening in the child component even though the input has clearly changed.

+3
angular typescript rxjs


source to share


No one has answered this question yet

See similar questions:

74
Angular2 change detection: ngOnChanges does not fire for nested object
7
ngOnChanges does not fire when input property changes

or similar:

33
Angular 2 - Passing data to child component after parent initialization
fourteen
Update parent component property from child component in Angular 2
nine
Insert parent component of the same type as the child component
4
How to reload child components based on some events from parent (RC4)
1
Angled bi-directional component binding does not call parent ngOnChange
1
Does the array convert the object after @Input () to a child?
1
How to pass an object from parent component to child component that is created using DCL loadintolocation ()?
1
How does two-way binding work in Angular 2?
0
How to make the child see the change of the parent variable
-1
Angular 6 - Displays dropdown list of child component after receiving data from REST service in parent component



All Articles
Loading...
X
Show
Funny
Dev
Pics