This is my first time using Angularjs $resource and I am trying to do some testing on my application. I am trying access one of the properties instead of showing the entire object. How can I access data.image or data.url?
json data from weather underground
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
}
, "current_observation": {
"image": {
"url":"http://icons.wxug.com/graphics/wu2/logo_130x80.png",
"title":"Weather Underground",
"link":"http://www.wunderground.com"
},
"display_location": {
"full":"San Francisco, CA"
}
weather factory
app.factory('weatherService',['$resource', function($resource){
var factory={};
factory.getWeather = function(){
return $resource("http://api.wunderground.com/api/9eb7777065b59c55/conditions/q/CA/San_Francisco.json").get();
}
return factory;
}]);
weather controller
app.controller('weather', ['$scope', '$http','weatherService', function($scope, $http, weatherService){
$scope.weather = weatherService.getWeather().get();
}]);
.get()twice ? Once inside factory and once inside controller ?