You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<template repeat="{{item in items}}">
<prog-bar
name="{{item.name}}" >
</prog-bar>
</template
Now I want each prog-bar element to get also it's index in the list of items, So I add something like this:
<template repeat="{{item,i in items}}">
<prog-bar
index="{{i}}"
name="{{item.name}}" >
</prog-bar>
</template
Unfortunately, this does not work. When the attachedCallback function is called the value of this.index is undefined. By putting a breakpoint in attachedCallback() I see that the elements are created one after the other but the value of index is undefined, when all of the items are loaded then suddenly the index appear.
If you wait until domReady, index will be defined if you want to poke at them in JS. This waits an additional frame after attached. By that time, the binding system will have populated the value.
I'm creating a list of items like this:
Now I want each prog-bar element to get also it's index in the list of items, So I add something like this:
Unfortunately, this does not work. When the attachedCallback function is called the value of this.index is undefined. By putting a breakpoint in attachedCallback() I see that the elements are created one after the other but the value of index is undefined, when all of the items are loaded then suddenly the index appear.
This led me to this solution:
...
Am I missing something or is there a problem with evaluating the repeat index?
The text was updated successfully, but these errors were encountered: