My Objective:
From a different component than shown below, I want to call the same service, and have it update this.displayData
in display.component.ts
My component that subscribes to a service for data to display on the UI.
display.component.ts
this.displayDataService.getDisplayData(items)
.subscribe(
(res: Result) => {
// when service is called from another component,
// I want this to update
this.displayData = res;
});
Here is my service which is being subscribed to
display-data.service.ts
public getDisplayData(items: Array<string>): Observable<any> {
return this.http.post(myEndpoint, items, headers).map(res => res.json());
}
The Problem:
Whenever I call the service from another component, it does not update the subscription in display.component.ts
How can I update the display.component subscription by calling the service from a different component? I thought every subscription would be updated when I called the shared service.
Note: I only have one instance of my service, which is in app.module.ts.