i just wanna get value from json request in ember services from component. this is my code
forecast-weather.js (services)
import Ember from 'ember';
export default Ember.Service.extend({
findWeatherCurrent:function (lat,lng) {
return Ember.$.getJSON('http://ift.tt/2mI80IJ'+ lat +','+lng+'?exclude=minutely,hourly,daily,flags&units=si');
},
findWeatherDaily:function (lat,lng) {
return Ember.$.getJSON('http://ift.tt/2mI80IJ'+ lat +','+lng+'?exclude=minutely,hourly,currently,flags&units=si');
},
findWeatherHourly:function (lat,lng) {
return Ember.$.getJSON('http://ift.tt/2mI80IJ'+ lat +','+lng+'?exclude=minutely,daily,currently,flags&units=si');
}
});
weather-display.js (component)
import Ember from 'ember';
export default Ember.Component.extend({
forecastWeather:Ember.inject.service(),
willRender(){
let lat = this.get('lat');
let lng = this.get('lng');
this.get('forecastWeather').findWeatherCurrent(lat,lng).then(data => {
this.set('currents', data);
console.log(data);
});
}
});
jsonRespon
{
"latitude": 37.8267,
"longitude": -122.4233,
"timezone": "America/Los_Angeles",
"offset": -7,
"currently": {
"time": 1489488513,
"summary": "Clear",
"icon": "clear-night",
"nearestStormDistance": 47,
"nearestStormBearing": 87,
"precipIntensity": 0,
"precipProbability": 0,
"temperature": 13.54,
"apparentTemperature": 13.54,
"dewPoint": 8.59,
"humidity": 0.72,
"windSpeed": 0.87,
"windBearing": 46,
"visibility": 12.46,
"cloudCover": 0.08,
"pressure": 1016.58,
"ozone": 279.62
}
}
weather-display.hbs
<p id="word_on_change" class="font_black font-white word"></p>
i just wanna passing that windspeed value from json to hbs template, but it doesnt working. can anyone solve this :(
Aucun commentaire:
Enregistrer un commentaire