0

I have gone through a few posts and I am still having trouble accessing nested object data. I am using a factory to fetch weather info using jsonp:

this.testApi = function(coords) {
        var deferred = $q.defer();

        $http.jsonp(API_ROOTS + '?key=khjsgf7bhv3y3hy776763&q=' + coords.latitude + ',' + coords.longitude + '&cc=yes&includeLocation=yes&format=json&callback=JSON_CALLBACK')
        .then(function(response) {
          deferred.resolve(response.data);
          console.log(response.data.data);

        }, function(error) {
            deferred.reject(error);
        }
        );
        return deferred.promise;
    };

this returns a response that looks like this:

Object {current_condition: Array[1], nearest_area: Array[1], request: Array[1], weather: Array[5]}

now inside, lets say, current_condition, it looks like this:

0: Object
FeelsLikeC: "17"
FeelsLikeF: "63"
cloudcover: "0"
humidity: "23"
observation_time: "09:51 AM"
precipMM: "0.0"
pressure: "1028"
temp_C: "17"
temp_F: "63"
visibility: "10"
weatherCode: "113"
weatherDesc: Array[1]
weatherIconUrl: Array[1]
winddir16Point: "WSW"
winddirDegree: "250"
windspeedKmph: "7"
windspeedMiles: "4"
__proto__: Object
length: 1
__proto__: Array[0]

the only problem is when I try access it in my html I get no out put:

{{place.current_condition.FeelsLikeC}}

does not seem to output anything...

3
  • {{places[0].current_condition.FeelsLikeC}} If places is a list Commented Aug 3, 2015 at 10:10
  • hey sorry, yes place is an object. Mistyped. here is the full json output that I am getting: [link]plnkr.co/edit/oyNboaZm0BtamnjuDypx?p=catalogue[/link] if, in my factory i output deferred.resolve(response.data.data); I get the json output in the plunkr Commented Aug 3, 2015 at 10:27
  • 1
    {{place.current_condition[0].FeelsLikeC}} Commented Aug 3, 2015 at 10:31

1 Answer 1

3

If places is javascript object, then you can use

places.current_condition[0].FeelsLikeC

If places is array, you can use something like

places[0].current_condition[0].FeelsLikeC

as current_condition is an array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.