2016-06-14 76 views
0

更改为使其更清晰。dom中重复的聚合物模板 - 如果

<template is="dom-repeat" items="{{survey.Questions}}"> 
    <template is="dom-if" restamp if="{{isFormat(item.Type, 'Single-Select')}}"> 
    <question-singleselect question="{{item}}" auth-Data="{{authData}}"></question-singleselect> 
    </template> 
    <template is="dom-if" restamp if="{{isFormat(item.Type,'Open-Ended'}}"> 
    <question-openended question="{{item}}" auth-Data="{{authData}}"></question-openended> 
    </template> 
    <template is="dom-if" restamp if="{{isFormat(item.Type,'Text Block'}}"> 
    <question-textblock question="{{item}}" auth-Data="{{authData}}"></question-textblock> 
    </template> 
    <template is="dom-if" if="{{[[}}isFormat(item.Type,'Numerical'}}"> 
    D: {{item.Type}} 
    <question-numerical question="{{item}}" auth-Data="{{authData}}"></question-numerical> 
    </template> 
</template> 

这里是我的代码与功能加入,其中规定的其为真或假。

我具有一种类型,对于每一个上面列出的元件的,所以4个记录的阵列。

结果表明从阵列中的记录,但上述模板与DOM-如果节目中的每个元素的每个记录。例如,具有数字类型的数据将显示在上面显示的每个部分中,而不是隐藏它们。

在对象的问题,我们有不同类型的调查问题,但是当我们通过调查对象,问题是重复在不同的格式通常是在不同的问题模板类型...这是。 ...问题1将在问题类型1(比如单选按钮)和问题类型2(比如复选框)下显示,尽管它在调查中返回的json中列为类型1。

我是否使用dom-repeat和dom-如果正确?不知道我错过了什么。

回答

1

聚合物不支持绑定中的表达式。另请参见How do I write condition in polymer1.0 with "dom-if"?

dom-repeat很好我猜是从什么可以说没有看到代码。

+0

你的修复是正确的,卜如果你看到我的更新上面的代码,我缺少一个右括号,没有出现任何调试器或棉短绒,或类似的东西....所以那种很烂,这些简单的错别字不显示。 –

+0

我明白了。我不知道有关棉绒或类似物的计划。我目前没有太多参与聚合物。 –