Page 1 of 1

how to get the i value of an iteration ?

Posted: Tue Jun 30, 2015 3:03 am
by sdanigo

Hi,
certainly a stupid question but, how to get the 'i' of an iteration when we map an array on a screen?
I mean, I want to know on wich iteration we are.
Can someone provide a JS code for that ?

Thanks

Sylvain


how to get the i value of an iteration ?

Posted: Tue Jun 30, 2015 4:06 am
by sdanigo

Found an answer
for those who are interested, here is my solution (may be not the best but working):

var indexElement=element[0].attributes._idx.nodeValue;
indexElement=indexElement.substring(1);
console.log(parseInt(indexElement,10));

in the mapping, where you put your 'i' collection