So I am trying to subscribe to a simple service that return data from a local JSON file.
I have managed to get the service working, I can log it out in the function
you can do it like this:
In your app-component:
public getDataFromService() { this._api.getData(this); } public setData(data: any){ this.data=data; }
In your service/api.ts:
public getData(obj: appComponentModel){ this.http.get(url).subscribe(res => obj.setData(res)); }