И ещё, надеюсь крайняя на сей момент проблема: служба в службу
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import { Settings} from './settings';
import { GetlocationService } from './getlocation.service';
@Injectable()
export class GetweatherService {
constructor(private http: Http, private _getlocationservice: GetlocationService) {}
coordData: any;
getWeatheritemsbyCoords(): Observable<any>{
this._getlocationservice.getCurrentPosition().subscribe(
data => {this.coordData = data},
error => console.log('Error fetching geolocation data'));
console.log(this.coordData)
return this.http.get(Settings.BaseURL+'?lat='+this.coordData.coords.latitude+'&lon='+this.coordData.coords.longitude+'&APPID='+Settings.APPID)
.map(response => response.json());
//return this.http.get(Settings.BaseURL+'?lat='65.785645&lon=33.106754&APPID='+Settings.APPID)
//.map(response => response.json()); - Так работает
}
}
лог:
ERROR TypeError: this.coordData is undefined
Если можно?...