I have 2 option set (picklist) and I would like to populate one of them based on the other option set. for example if I have the arrays in the ts file:
carsArray: { id: number, name: string }[] = [
{ "id": 1, "name": "Car1" },
{ "id": 2, "name": "Car2" },
{ "id": 3, "name": "Car3" }
];
carModulesArray:{ id: number, carId:number ,name: string }[] = [
{ "id": 1, "carId":1, "name": "Module1" },
{ "id": 2, "carId":1, "name": "Module2" },
{ "id": 3, "carId":1,"name": "Module3" },
{ "id": 4, "carId":2,"name": "Module4" },
{ "id": 5, "carId":3,"name": "Module5" }
];
and in the html template
<select id='cars'>
<option *ngFor="let c of carsArray"
value="{{c.id}}">{{c.name}}</option>
</select>
<select id='modules'>
<option *ngFor="let m of carModulesArray"
value="{{m.id}}">{{m.name}}</option>
</select>
How can I make the second picklist (modules) be dynamicly populated by the first picklist (cars) so after the user select car 1 he see modules 1,2 and 3 only and if he select car 2 (or 3) he see module 2 (or module 3)
Thanks in advance for the help