聚合物绑定条件属性和评估属性

Polymer bind conditional attribute and evaluate attribute

我想知道是否可以使用 Polymer 表达式将属性有条件地绑定到元素,同时在绑定为真时为其赋值?

我知道如何分别做这两件事:

pattern?="{{someBoolean}}"

pattern="{{someBoolean ? 'value if true' : 'value if false'}}"

但在不使用元素原型中定义的额外 javascript 的情况下未能成功完成这两项工作。

感谢任何帮助或建议!

编辑:

在上面的例子中

if (someBoolean)
<input pattern="value if true"/>
else if (!someBoolean)
//pattern attribute is not bound and attribute assignment does not occur
<input/>

你可以做到

<template if="{{ boolean }}">
  {{ patternIfTrue }}
</template>

不过我认为这可能会在 polymer 0.8 中改变。

我不明白这是什么意思。 在哪种情况下,您需要将属性 conditionnaly 与另一个值为 true 的值绑定? 在所有 HTML 属性中,您需要指定一个值,或者它是您应该从 dom 中删除的条件属性(例如:隐藏="true"),因为某些浏览器会未读取值(例如:hidden="false" 可能在某些浏览器中隐藏)