1
<template is="dom-repeat" items="{{items}}" as="first">
    <template is="dom-repeat" items="{{first}}" as="second">
        <span on-tap="test">{{second}}</span>
    </template>
</template>

items: [["1","2"],["3","4"]],
test: function (e) {
    // access e.model of first
}

是否可以访问外部重复循环的 e.model?仅仅获得对象是不够的(尽管这将是一个开始)。我需要模型变量在其上使用 push/pop。令我惊讶的是 e.model.first 不存在。

4

1 回答 1

2
<template is="dom-repeat" id="firstRepeat" items="{{items}}" as="first">
    <template is="dom-repeat" id="secondRepeat" items="{{first}}" as="second">
        <span on-tap="test">{{second}}</span>
    </template>
</template>

<script>
  items: [["1","2"],["3","4"]],
  test: function (e) {
    // First model
    this.$.firstRepeat.modelForElement(e.target);

    // Second model
    this.$.secondRepeat.modelForElement(e.target);
  }
</script>
于 2015-06-10T18:03:45.477 回答