sending json obj to polymer element and it's not working! :/

77 views
Skip to first unread message

babak slt

unread,
Jul 25, 2014, 4:32:37 PM7/25/14
to polym...@googlegroups.com

I have no idea why is this happening! i want to send an object to polymer element and then use it. im using something like this for the element

<polymer-element name="post-thumb" attributes="post">
  <template>
    <article>
      <span>this is a post thumb</span>
        <h1>{{post.title}}</h1>
        <p>{{post.body}}</p>
    </article>
  </template>
  <script>
  Polymer('post-thumb');
  </script>
</polymer-element>

and after HTML import, i'm calling it like this:

<post-thumb post='{"title":"post title 1","body":"post body"}'> </post-thumb>

it's weird cause when i use {{post}} it'll bring back the whole {"title":"post title 1","body":"post body"} but when i use {{post.title}} polymer simply returns nothing!

what's wrong here!? :/


http://stackoverflow.com/questions/24963929/sending-json-obj-to-polymer-element

Rob Dodson

unread,
Jul 25, 2014, 4:34:48 PM7/25/14
to babak slt, polymer-dev

On your element prototype set post: {}

You need to hint to polymer that it should treat that property as an object instead of a string

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/b8f4a9c2-c68a-4957-922f-0673d687e228%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

babak slt

unread,
Jul 25, 2014, 4:45:03 PM7/25/14
to polym...@googlegroups.com, baba...@gmail.com
oh. thanks. maybe i should read the API developer guide again!
thanks a lot. 
Reply all
Reply to author
Forward
0 new messages