嵌套重复中的聚合物 1.0 访问父 e.model
Polymer 1.0 access parent e.model in nested repeats
<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 不存在。
<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>
<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 不存在。
<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>