I have my data in below:
fakeData = [
{
"option_name" : 'optionA',
"display_line_num" : 1
},
{
"option_name" : 'optionB',
"display_line_num" : 2
},
{
"option_name" : 'optionC',
"display_line_num" : 2
},
{
"option_name" : 'optionD',
"display_line_num" : 3
},
{
"option_name" : 'optionE',
"display_line_num" : 4
},
{
"option_name" : 'optionF',
"display_line_num" : 4
}
];
and I am trying to make my html look like desired look
The display_line_num represent which row the element should be placed. I am pretty lost on how to approach to this.
my try here I tried to create a hashmap where key is the line number, and value is how many options are in that line number. However, I am still lost. I am stuck for a long time, and I wonder what are some good ways to approach this?
I know that we may need to use *ngFor, for example , <li *ngFor="let item of items;"> ....
but there will be a nested for loop which one row can have several options, and sometimes a row only has a option. How can I handle these circumstances?
Can someone give me a hint? Thank you!