My challenge is sharing an object between two components. The parent component holds the global instance of the object, and the two child components receive that instance through two-way data binding. However, despite the changes being propagated, the set function linked to that field is not being executed.
@Output() consultChanged = new EventEmitter<Consult>();
@Input()
set consult(consult: Consult) {
console.log("Code to run when there is a change");
this._consult = consult;
this.consultChanged.emit(this._consult);
}
Check out this example on stackblitz where the console.log is not triggered.
UPDATE: I am aiming for a behavior where all components sharing that variable call their setters when it changes (to update other variables with the new values). If you have alternative methods to achieve this, I am open to suggestions.