2015-02-12 56 views
0

如何通过foreach实例作为方法参数?如何通过foreach实例作为方法参数?

在下面的代码中,我如何将每个实例currentFeature传递给$root.enableDemote(currentFeature)。将它作为$root.enableDemote(currentFeature)传递不起作用。任何sugegstions?

<tbody data-bind="foreach: { data: features, as: 'currentFeature' }"> 
    <tr> 
     <td style="width: 8px;"> 
      <button type="button" id="exposureDetailDemoteButton" class="btn btn-default fe-margin" data-bind="click: $root.demoteExposure, enable: $root.enableDemote(currentFeature)" data-toggle="tooltip" title="Demote Feature Exposure"><span class="glyphicon glyphicon-backward"></span></button> 
     </td> 
    </tr> 
</tbody> 

回答

2

$数据是 “的foreach” 结合内部的当前阵列条目:

data-bind="click: $root.demoteExposure, enable: $root.enableDemote($data)" 

另外$指数是迭代指数(观察到的)。欲了解更多详情,请登录foreach binding documentation

+0

完美。 st.fwd – 2015-02-12 07:23:19

+1

非常感谢你:) – TSV 2015-02-12 07:33:46

相关问题