Creating private variable in a repeating list

Hi guys,

I’m trying to create a repeating list served from an API with a unique counter for each row to indicate the quantity per item, I created this as a component and defined a private variable for the counter, and basically added a simple logic to increment / decrement the quantity when pressing the +/- buttons respectively.

The counter works just fine in the component but it stops working when the component is repeating from the API response, I checked in debug mode and the counter value is being updated properly but for some reason it’s not updating in the UI as it’s always showing the initial value.

Would appreciate your help on this, did a lot of research but couldn’t find anything that solves this issue

Hi, i wasnt able to read your post very carefully, but i think this will solve your issue, you will need to play around to figure it out. Instead of private variable, try using a property and set it to two way binding. that way, you could set the price from outside the composite component.

Hope this helps

1 Like

Hi @Dimos_Vamvourellis, thanks for your reply earlier and trust me I’ve been stuck on this issue since then, didn’t want to reply without trying all possible solutions. I added a new property as suggested and tried setting from inside the custom component and from outside but it didn’t work.

I don’t want to set the price, but simply to add a counter per repeated list item, to act as the number of items to add to cart per row, unfortunately I cannot have a unique property per list item, all of them are changing at the same time as you can see here

Appreciating your help here and thank you so much in advance

Hmm, to tell you the truth, i cant figure it out, maybe
can help!

@Osama_H From what you described I think you may have added a new property to the whole composite component when what you need to do is add a new property to the internal data variable for this to work :slight_smile: