Hi Daniel,
Thank you for pointing out the original problem. However, now I can be sure
that my data type is an array. The typeof posts showing on console display
as following:
object [ '{"Name":"aaa","Address":"bbb","Phone":"1111"}',
'{"Name":"ccc","Address":"ddd","Phone":"2222"}',
'{"Name":"eee","Address":"fff","Phone":"3333"}' ]
This array object still fails when passing into <iron-list> tag. Looking at
the error handling below where it fails, it has something to do with the
JSON parser not getting the correct data format assuming 'value' is passed
with my 'posts' array. But as you can see and confirm above, the 'posts'
data element format should meet the JSON parse standard unless there is
something else i overlooked. Thanks.
case Array:
try {
value = JSON.parse(value);
} catch (x) {
value = null;
console.warn('Polymer::Attributes: couldn`t decode Array as JSON');
}
break;
BR/Roger
Daniel Llewellyn於 2016年12月13日星期二 UTC+8下午10時00分11秒寫道:
>
>
>
> On Tue, 13 Dec 2016 at 03:49 <[email protected] <javascript:>> wrote:
>
>> Hi Daniel,
>>
>> And the console log will show my posts data as a type string
>> representation of my array strings. Thanks.
>>
>> string [{"Name":"aaa","Address":"bbb","Phone":"1111"},
>> {"Name":"ccc","Address":"ddd","Phone":"2222"},
>> {"Name":"eee","Address":"fff","Phone":"3333"}]
>>
>
> OK, that's your problem. `<iron-list>` takes an array, in the `items`
> property, not a string. You need to change your `posts` variable to contain
> an array, or use a different variable which does contain an array.
>
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/dd71a410-1dce-4fca-85ec-e52150623c59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.