get_update(id:any): Observable<any[]>{
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers });
return this.http.get('http://localhost:8000/vendor/'+id,options)
.map(response => response.json())
.catch(error => Observable.throw(error.statusText));
}
component.ts
ngOnInit()
{ this.service.get_update(this.user).subscribe(data => console.log(data));
}
component.ts datas to be stored in another variable
Declare a data member in your class and use it, and for sharing data you can use @input()
decorator @output
decorator or use a service.
export class AppComponent {
constructor(){}
public data=[];//
ngOnInit()
{ this.service.get_update(this.user).subscribe(data => this.data=data);
}