Skip to content
Advertisement

Binding issue in repeat.for in aurelia

I have a list of cards that i populate, when i click on each card i want to get and display the correct items displayed for that card. The problem i am facing is that when i return an array its not binding the correct item to the specific card.

This is my HTML

JavaScript

my ts

JavaScript

so this.categoryItemsTypes has the following array

JavaScript

so when the page loads it loads the cards as follows

LOADS GROUPING NAME NAME

then when i click on “Clothes” i only want it to load the array associated with clothes and if “shoes” is clicked then only load that array as follows

what i want

but what is currently happening with my above code is the following

wrong

this line is where i bind the items

JavaScript

how can i bind the items to the correct ${Grouping.name} as shown in picture 2?

Advertisement

Answer

You are in the right direction, but not complete yet. Array assignment are not observed by aurelia. In general, when populating arrays with a new set of elements, this is a good way:

destarray.splice(0, destarray.length, ...sourcearray);

over

destarray = sourcearray;

because the former is observed by aurelia by default and the latter is not.

Advertisement