I have come across an issue where I cannot figure out what would be approach to make a dynamic drop down menu with sub dropdowns that comes from database. I made api that pulls product categories and subcategories from database and it looks like this when I put it in model.
export class Category {
id : any;
parent_id : any;
name : any;
created : any;
modified : any;
status : any;
}
Example
|id | parent_id | name |
| 1 | 0 | cars |
| 2 | 1 | ford |
| 3 | 2 | focus |
| 4 | 0 | maincat2 |
| 5 | 4 | subcat |
| 6 | 1 | fiesta |
records with id 0 are are main in list records that have parent_id other than 0 are submenus etc
Can anyone give me an insight in what my approach can be, or to point me to some example or answer here that I may have overlooked because I have been researching for two days now, and I haven't found anything.
This is somehow close to what I am looking for to populate example menu