If I do the following, it works somewhat; that is, the variable is not interpolated, but instead passed on the Polymer Component as is, as the string, “theTitle”:
“Bound attributes” are coming in 1.11, but are behind a feature flag in Canary right now. So you’ll have to use {{bind-attr theTitle=theTitle}} for now.
When I use Ember 1.10.0.beta-1, your bind-attr suggestion works for bound properties that are strings, but not for properties that are arrays or objects. So I am half-way there, I presume. This is the error I am getting for array/object properties:
"Uncaught Error: Assertion Failed: Attributes must be numbers, strings or booleans, not [[object Object],[object Object]]"
In a follow up post, after I resolve this issue, I will share how the latest version of canary is throwing an error with the Polymer components, while Ember 1.10.0-beta-1 is working just fine with the same Polymer components.
“Uncaught Error: Assertion Failed: Attributes must be numbers, strings or booleans, not [[object Object],[object Object]]”
Are you sure it’s not because of {{bind-attr theTitle=theTitle}}, since “theTitle” is used for both the attribute name and value. You should try renaming one or the other.
If it truly is the other, {{bind-attr posts=postsArray}}, then do you have another property on the controller/view with the name of “posts”?
{{bind-attr}} and <div someThing={{foo-bar}}></div> are both going to ultimately call element.setAttribute, and you cannot call element.setAttribute('theTitle', ['adsf', 'basdf']);.
If you were to write this in plain HTML what would you need/want it to be (assuming for a second that the dynamicism wasn’t an issue)? Could you provide a JSBin (possibly one with Ember and one with plain HTML + Polymer) so we can poke at it a bit more?
@rwjblue I see what you mean, there are no array attributes. Side question, will this work with custom element Components? Eg, doesn’t it work now as {{foo-bar anArray=myArray}} and in 1.11 <foo-bar anArray={{myArray}}>?
Hi rwjblue, I want to pass just data, not HTML. I want to pass an array or an object, preferably bound data. As I noted above, I could pass a string successfully and it binds.
Within Polymer, you can pass all sorts of data (aka attributes) to a Polymer component in either of the following two ways:
@lamboo Can you share a JSBin that we can iterate on? My understanding is that polymer binds to properties so you will need to enable the bound-attributes feature flag and use foo={{bar}} for it to work.