$index+1 in Knockout foreach binding

前端 未结 2 1736
星月不相逢
星月不相逢 2021-01-31 14:28

I need to display $index+1 in a table.

If I just use the $index all the elements will start from 0, I need to start at 1.

Here\'s the

相关标签:
2条回答
  • 2021-01-31 14:34

    I found the answer here: Knockout is not evaluating an expression when using $index in a binding

    In order to use it <span data-bind="text: $index() + 1"></span>

    0 讨论(0)
  • 2021-01-31 14:55

    $index is an observable. So you need to use it this way :

    <span data-bind="text: ($index() + 1)"> </span>
    
    0 讨论(0)
提交回复
热议问题