2015-06-10 29 views
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并不存在。聚合物1.0在嵌套重复中访问父e.model

回答

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> 
+0

很好,谢谢! – user3253663