I have a shared-data.service.ts with some private properties, e.g.:
private _selectedId: string;
get selectedId(): string {
return this._selectedId;
}
set selectedId(value: string) {
this._selectedId = value;
}
I invoked this service in a component list.component.ts as a public object and used it directly in the component.
constructor(public sharedDataService: SharedDataService) {}
...
list: Defect[] = this.sharedDataService.getDefects(this.sharedDataService.selectedId)
Furthermore I used the service directly in the .html file of the component, i.e. list.component.html:
<div>{{sharedDataService.selectedId}}</div>
When I now update the value of _selectedId in the service via another component I have the following problem:
list: Defect[]doesn't get updated- but in list.component.html the content of the
<div>elem will be updated.
Why do the html part get the update, but list: Defect[] doens't get the update ?