superframe icon indicating copy to clipboard operation
superframe copied to clipboard

[state] Allow access to loop index in bind-for/bind-item

Open dsinni opened this issue 5 years ago • 3 comments

It would be great if bind-for and bind-item allowed access to the loop index so that it could be used for things such as numbering items as they are displayed (not necessarily as they are stored by id), or used to calculate positioning without needing to rely on something like the layout component, just to give a couple of examples.

If this is already possible, please forgive the issue, but I didn't anything obvious in the code or docs.

Thanks and keep up the great work!

dsinni avatar Jul 30 '19 01:07 dsinni

Yeah, that's a good idea. Having a component read its sibling index is a workaround.

ngokevin avatar Jul 30 '19 22:07 ngokevin

Thanks for the reply, @ngokevin.

Having a component read its sibling index is a workaround.

Sorry, would you mind elaborating just a bit on that? I'm not sure I'm following.

Appreciate your time.

dsinni avatar Jul 31 '19 00:07 dsinni

use JS to get the index of the element relative to parent

ngokevin avatar Jul 31 '19 02:07 ngokevin