I'm working on a reservation site where I have two select dropdown boxes with 3 identical city names. Depending on the choices in first dropdown, I want the second to adjust in a way that it's not possible to have equal values.
HTML:
<h4>Airport of Departure</h4>
<select name="" id="">
<option [value]="city" *ngFor="let city of opts">
{{city.key}}
</option>
</select>
<!-- chosen destination -->
<h4>Destination (must be different than departure location)</h4>
<select name="" id="">
<option [value]="city" *ngFor="let city of opts">
{{ city.key }}
</option>
</select>
COMPONENT.TS:
public cities = ["Warsaw", "Paris", "New York"];
public opts = [
{ key: "Warsaw", value: ["paris,new york"] },
{ key: "Paris", value: ["warsaw,new york"] },
{ key: "New York", value: ["warsaw, paris,"] }
];
STACKBLITZ: https://stackblitz.com/edit/flight-date-pikcer
I am having trouble figuring out the way to make this work. Thank you for your support!