Под Ionic4 и внутри компонента я вызвал сервис, который возвращает наблюдаемое. Мне удалось отобразить часть элементов структуры Json, но я не могу сделать это в своем шаблоне.
// WeatherService.ts
getWeather(item):Observable<Weather>
{
this.ApIurl = `http://api.openweathermap.org/data/2.5/weather?q=${item.city}&units=metric&appid=${this.apikey}`;
// console.log(this.ApIurl);
return this.http.get<Weather>(this.ApIurl);
}
//details.ts
// weatherS declared of type WeatherService
this.weatherS.getWeather(this.locationDetails)
.subscribe(
dt => {
this.data$ = dt;
// display temperature works fine
console.log(this.data.main.temp);
//json content returned
{
"temp": 23,
"pressure": 1015,
"humidity": 64,
"temp_min": 22,
"temp_max": 24
}
к сожалению, я не могу отобразить в своем шаблоне details.html data $ .temp или любые другие значения, хотя мне удается отобразить всю структуру с помощью {{data $ | JSON}}