我想在表格上显示dom-repeat的第一个元素。其他应通过单击按钮添加。在聚合物中如何可能出现这种情况。如图所示。
如上图所示,默认情况下应显示room#1,单击按钮应从room#2开始添加。
码-
<form is="iron-form" id="form" method="post" action="/form/handler">
<template is='dom-repeat' items='{{ rooms }}'>
<div class="head">
<paper-item>
<div id="line"><span>Room# {{displayIndex(index)}}</span></div>
<template is='dom-if' if='{{displayIndex != 1}}'>
<paper-button toggles class=button on-click="deleteRoom"><img src="trash.png" height="20px" width="20px"></paper-button>
</template>
</paper-item>
</div>
<choice-form room="{{displayIndex(index)}}">{{ item.room }}</choice-form>
</template>
</form>
最佳答案
我将创建一个仅包含第一个房间(room#1)的新数组,然后单击按钮,将room#2添加到该数组,然后在dom-repeat
而不是rooms
中使用此数组。