I'm trying to find a better approach to handle complex angular forms. The form has many cascading dropdowns, and I need to find an approach to reduce complexity.
Below Validations I'm trying to achieve:
The first two are not validations, they are actions you need to take upon an event happening, namely a change of selected value in your drop-downs. So you need to have something like:
<select (change)="onChange1()" formControlName="yourDealerDD1">
<option *ngFor="..." [ngValue]="record.id">{{record.name}}</option>
</select>
<select formControlName="yourMakerDD1">
<option *ngFor="for brand of makerBrands" [ngValue]="brand.id">{{brand.displayName}}</option>
</select>
where onChange1()
is a function that will be called when you change value on your drop-down named as yourDealerDD1
in your reactive form. In that function, you can filter and set the makerBrands, so that yourMakerDD1
drop-down displays the appropriate options.
I cannot answer all your queries, but if I were you, I would start by reading about the following:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.