Trying to set the values for the dropdown using foreach method, But not working properly. It is loading 5 times for each dropdown. I want to show the proper value for the dropdown. Example: For Car dropdown I want to show only the value of Car from the array. Same like for others. So, How to do it?
main.component.html:
<div
class="custom-select"
style="width:400px;"
*ngFor="let v of vehicle; index as i"
>
<p>{{ v }}</p>
<app-vehicle [data]="travals"></app-vehicle>
</div>
Demo: https://stackblitz.com/edit/angular-ivy-yxfoyl?file=src%2Fapp%2Fmain%2Fmain.component.html
This's what you need?
vehicle.component.html
<select>
<option
*ngFor="let vehicleType of data; index as i"
value="{{ vehicleType }}"
label="{{ vehicleType }}"
></option>
</select>
main.component.html
<div
class="custom-select"
style="width:400px;"
*ngFor="let v of vehicle; index as i"
>
<p>{{ v }}</p>
<app-vehicle [data]="travals[v]"></app-vehicle>
</div>
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.