Can we pass JSON as Custom Attributes.

2,224 views
Skip to first unread message

maks...@gmail.com

unread,
May 22, 2014, 4:09:05 PM5/22/14
to polym...@googlegroups.com
I would like to know if JSON can be passed as Custom Attributes and can be accessed in the Polymer Element data binding?

Eric Bidelman

unread,
May 22, 2014, 4:40:58 PM5/22/14
to maks...@gmail.com, polymer-dev


On Thu, May 22, 2014 at 1:09 PM, <maks...@gmail.com> wrote:
I would like to know if JSON can be passed as Custom Attributes and can be accessed in the Polymer Element data binding?

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 polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/e18ab0cc-5910-4740-b721-f7d893974c94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

maks...@gmail.com

unread,
May 23, 2014, 2:03:16 PM5/23/14
to polym...@googlegroups.com, maks...@gmail.com
I am not successful. When i tried the below

<master-elem datee ='[{"name":"John"}, {"name":"Bob"}]'></master-elem>

and read the value as below - I am getting undefined but I am able to read the value from the Polymer construction or any events in it.

polymer-element name="master-elem" attributes="letters datee">
    <template>
        <template repeat="{{d in datee}}">
            <my-elem name={{d.name}}
                     valuee=true></my-elem>
        </template>
       
    </template>
    <script>

Can you please help?

Steve Orvell

unread,
May 23, 2014, 2:34:02 PM5/23/14
to maks...@gmail.com, polym...@googlegroups.com
In order to deserialize as an object, the `datee` must be an object. You can do this:

Here's an example: http://jsbin.com/nozuj/1/edit


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 polymer-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages