I have a parent component with two children.
The parent component has a property which is actually a dictonary like this:
dict = {a: 0, b: 0, c: 0};
I do input binding so that both of the child components can have access to dict
.
<app-child-a [dict]="dict"></app-child-a>
<app-child-b [dict]="dict"></app-child-b>
Child A changes a property of dict
@Input() dict: any;
someFunctionInChildA() {
this.dict.b = 1;
}
I can verify that the Parent component knows about this change.
ngAfterInit() {
setInterval(() => console.log(this.dict), 1000);
}
This prints 0
s until someFunctionInChildA
is triggered after which it prints 1
s.
Here's my problem: child B doesn't seem to see the change. Here's some code from child B
@Input() dict: any;
ngAfterInit() {
setInterval(() => console.log(this.dict), 1000);
}
This prints 0
s all the time, even after someFunctionInChildA
has been triggered.
Do I not understand how property binding works? Or is it more likely that I have a silly or unrelated bug elsewhere?