2015-06-10 54 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