I can use iron-ajax with Polymer 0.9.0-rc1 to retrieve a JSON object and
display a value in the template like so:
<dom-module id="my-element">
<template>
<iron-ajax
url="http://api.openweathermap.org/data/2.5/weather?type=accurate&units=imperial&cnt=1&q=Charlottesville"
auto last-response="{{resp}}"></iron-ajax>
<textarea value="{{resp.main.temp}}"></textarea>
</template>
</dom-module>
<script>
Polymer({
is: 'my-element',
properties: {
resp: {
type: Object
}
}
});
</script>
This also works with a simple JSON object retrieved from a public HTML
directory on my localhost. However I try to access an object in an array,
I'm told the object is undefined. For example, if the JSON array contains
two objects called "queries", <textarea value="{{resp.queries}}"></textarea>
displays "[object Object],[object Object]". However if I attempt, <textarea
value="{{resp.queries[0]}}"></textarea> or <textarea
value="{{resp.queries[0].title}}"></textarea>, the displayed value is "
undefined".
Am I doing something wrong? Is this a known shortcoming? Is there a work
around?
Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/polymer-dev/efbcd957-8429-4162-b05b-6a5bbd78a771%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.