Within my code, there is a toSpecialities
object containing two arrays: specialitiesOptions
and specialities
. This object is passed from a parent component to a child component.
this.toSpecialities = { specialitiesOptions: specialities, specialities: this.exerciseFramework.specialities };
<ef-specialties [data]="toSpecialities"></ef-specialties>
Within the child component, I utilized the ngOnChanges
function to monitor any changes in the object.
@Component({
selector: 'ef-specialties'
})
export class SpecialtiesComponent implements OnChanges {
@Input()
public data: any;
constructor() { }
ngOnChanges(changes: SimpleChanges) {
if (changes["data"] && changes["data"].currentValue) {
console.log(changes["data"]);
}
}
}
However, when attempting to update the specialities
, the change in the toSpecialities
object within the child component is not detected.
this.toSpecialities.specialities = this.array.specialities;