Also, thinking more about your issue proper, it seems the problem is the 
interpretation of your Object per se. 

What your child element probably needs to know is the string representation 
of the JSON object so it can deduce it inside using the JSON.parse() method 
I stated earlier.

For that, you could do the following where you are declaring your actual 
element:


   - Your flag attribute needs to be set via Javacript. A typical jQuery 
   way would be:
    
    var flagVariable = JSON.stringify(jsobject);
    $("child-element").attr("flag", flagVariable);
   
   - Once this is done, within the Polymer declaration of child-element, 
   you would be getting the attribute "flag" as a string now. There, you could 
   simply parse that string as JSON.parse(flag) //

This might just work. The reasoning is that string is a streamlined type 
used here to pass information, and then interpret it in its correct JSON 
format where required. Would love to hear back if this worked [ or was 
completely irrelevant - then we could probably dig deeper! :) ]


On Tuesday, July 8, 2014 4:12:16 PM UTC-7, Aakar Desai wrote:
>
> Hey Junius, 
>
> I faced a similar issue, but if it is a work-around you need, then inside 
> the "ready" method of Polymer, I tried parsing the string (in this case 
> "jsobject") as JSON with JSON.parse() , and it worked. Not saying this is 
> the best way to do it though. 
>
> Aakar
>
> On Monday, March 24, 2014 2:56:07 PM UTC-7, Junius Gunaratne wrote:
>>
>> Is there a proper way to pass JS objects to child elements? I'm trying to 
>> pass a JS object to a child element as an attribute. This worked in Polymer 
>> 0.2.0, but in 0.2.1 the object is changed to a string and I get 
>> [Object][Object] as a string in the child element instead of the actual JS 
>> object.
>>
>> <parent-element>
>>   <child-element flag="{{jsobject}}"></child-element>
>> </parent-element>
>>
>

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/cc36ab39-264b-4cd3-b4f3-8fcc7c4b401c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to