聚合物1.0:与<铁 - 元素的数据结合变量>元素(值属性) [英] Polymer 1.0: Data binding variable to <iron-meta> element (value attribute)
问题描述
{{str}}
的数据绑定到一个< iron-meta>
元素(父元素中的标签)如下。 失败:
< iron-meta id =metakey =infovalue ={{str}}>< / iron-meta>
上述代码中断。但是以下代码的工作原理(没有绑定)。
这样做:
< iron-meta id =metakey =infovalue =foo / bar>< / iron-meta>
区别在于变量版本 {{str}}
失败,常量版本foo / bar
的作品。
有没有人有提示什么是打破绑定和如何解决?
针对评论问题编辑:
-
如何失败?这无声无息。我打印出的数值根本不会更新,当我按登录和注册按钮。
您需要使用属性绑定,而不是绑定属性
< input type =textvalue $ ={{str}}/>
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:
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.
Here is a link to the code in a Github repository. See lines
You need to use an attribute binding and not a property binding
<input type="text" value$="{{str}}" />
这篇关于聚合物1.0:与<铁 - 元素的数据结合变量>元素(值属性)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!