Polymer 0.8中的嵌套x重复元素
是否可以执行以下操作:Polymer 0.8中的嵌套x重复元素,polymer,Polymer,是否可以执行以下操作: <template is="x-repeat" items="{{dataSource}}"> <!--called item--> <tr> <template is="x-repeat" items="{{columns}}"> <!--also called item--> <td data-titl
<template is="x-repeat" items="{{dataSource}}"> <!--called item-->
<tr>
<template is="x-repeat" items="{{columns}}"> <!--also called item-->
<td data-title$="{{itemFromSecondRepeat.displayName}}">
{{}} <!--How to {{itemfromtopRepeat[itemFromSecondRepeat.name]}}-->
</td>
</template>
</tr>
</template>
{{}}
问题是在这个x-repeat元素中,我不知道如何访问项目,这是
0.8
中的设计约束,还是有方法指定名称,例如{i in items}
中的0.5
?是的,这是可能的,但只有在绑定到项目的子属性时。看
例如:
<template is="x-repeat" items="{{rows}}">
<div>
<span>{{item.letter}}</span>
<template is="x-repeat" items="{{item.columns}}">
<span>{{item.number}}</span>
</template>
</div>
</template>
产生以下结果:
A 1 2
B 3 4
在测试时,我发现一件有趣的事情是Polymer无法将{{{item}}
绑定到嵌套自定义元素的属性。相反,它似乎只有在传递项的单个子属性时才起作用
<x-grid-cell color={{item.color}}></x-grid-cell> // works
//有效
vs
//似乎不起作用
<x-grid-cell color={{item.color}}></x-grid-cell> // works
<x-grid-cell cell={{item}}></x-grid-cell> // doesn't seem to work