2015-02-12 4 views
0

Как передать параметр foreach как параметр метода?Как передать экземпляр foreach в качестве параметра метода?

В приведенном ниже коде, как передать экземпляр foreach currentFeature в $root.enableDemote(currentFeature). Передача его как $root.enableDemote(currentFeature) не работает. Любые сугубости?

<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

$ данных является текущий элемент массива внутри "Еогеасп" связывания:

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

также $ индекс индекс итерации (наблюдаемое). Для получения дополнительной информации см. foreach binding documentation.

+0

безупречный.! st.fwd –

+1

спасибо за добрые слова :) – TSV

Смежные вопросы