Polymer 1.0: Data binding variable to <iron-meta> element (value attribute)
Asked Answered
U

1

1

In Polymer 1.0, I am trying to data bind a string variable {{str}} to an <iron-meta> element (tag in parent element) as follows.

This fails:

<iron-meta id="meta" key="info" value="{{str}}"></iron-meta>

The above code breaks. But the following code works (without the binding).

This works:

<iron-meta id="meta" key="info" value="foo/bar"></iron-meta>

The difference is the variable version {{str}} fails and the constant version "foo/bar" works.

Does anyone have a clue what is what is breaking the binding and how to fix it?

Edits in response to comment questions:

  1. How does it fail? This fails silently. The values I have printed out simply do not update when I press the Login and Register buttons.

  2. Here is a link to the code in a Github repository. See lines

Ulster answered 8/7, 2015 at 3:18 Comment(1)
How does it fail? Do you get any errors at all? Where/how is str declared?Mounts
A
2

You need to use an attribute binding and not a property binding

<input type="text" value$="{{str}}" />
Awning answered 8/7, 2015 at 14:55 Comment(2)
Both versions of the binding syntax work as expected. Specifically, value="{{str}}" AND value$={{str}} both work.Ulster
I am confused by the answer, the code has no input element to bind to? Also if assumed epascarello refers to the iron-selector by his example, it actually has a property 'value' (not attribute value), why should you use value$={{..}} to set it? @Mowzer can you also please further clear what you meant by your comment?Odilia

© 2022 - 2024 — McMap. All rights reserved.