knockout.js - How to get a count going inside a Knockout foreach loop? -


I have a standard foreach, and the loop is working correctly:

  & Lt;! - M8 to Forehack: My Collection - & gt; & Lt; Div id = "panel1" / & gt; & Lt ;! - / m7ko - & gt; To make it easier, all that I want to do is replace the constant id of the code with  panel 1   panel1 ,  panel2 , < Loop like code> Panel 3 , etc.  $ index  and  attr    

code> binding Something like this

  & lt; Div data-bound = 'atri: {id:' panel '+ $ index () + 1}' & gt; & Lt; / Div & gt;  

Where the $ index represents the current position of that element in the array KO is
It is possibly cleaner that it was calculated, but the logic Very similar.


Comments