1

I'm quite new to angular and would appreciate some help. I wanna make a function that call service with a google placeid as parameter and I want that service to return me the detailed google place object. I want to be able to access placeResult value in my component.ts and really have a hard time.

This is my function my service.ts file

getPlaceDetails(placeid: string) {
  this.getPlaceService.getDetails({
    placeId: placeid
  }, (placeResult, status) => {
    if(status === 'OK') {
      return placeResult;
    }
  });
}

and this is where I call my service function in my component.ts file 

selectCity(res) {
  this.httpService.getPlaceDetails(res['item']['place_id']).subscribe(data => {
    console.log(data);
  });
}
The Fabio
  • 5,369
  • 1
  • 25
  • 55
  • Assuming `res.item.place_id` is a string... what is getDetails inside GetPlaceService? and why would it return data if it's an observable? are you calling `getDetails.next(...)` anywhere? – Iancovici Feb 09 '18 at 00:45
  • yes res.item.place_id is a string and getDetails is from agm import https://stackoverflow.com/questions/47461548/angular-2-agm-library-for-google-maps-setting-place-by-place-id?rq=1 I took it from there, and for your last question I'm not sure, it's the part I'm confused about – Pierre-Olivier Morin Feb 09 '18 at 01:54

0 Answers0