I have a Select field:
<select
id="aircraft_id"
data-id="{{( $obj->exists ) ? $obj->aircraft_id : NULL}}"
data-placeholder="Wähle ein Flugzeug"
no-results-text="'Konnte kein Flugzeug finden'"
class="form-control"
chosen="directiveOptions"
name="aircraft_id"
ng-model="aircraft"
ng-change="checkSeats(aircraft.id)"
ng-disabled="newAircraftIdentifier.length > 0 || newAircraftModel.length > 0"
ng-options="aircraft.ident for aircraft in aircrafts">
</select>
and "aircrafts" json object contains:
[Object { ident="--", id="", seats=""},
Object { id=1, ident="D-3417", seats=2},
Object { id=2, ident="D-1021", seats=2},
Object { id=3, ident="D-4582", seats=1},
Object { id=5, ident="D-FTSD", seats=null},
Object { id=10, ident="D-5970", seats=1}
]
Everything works except that my option in the select is the index of my json Object, and not the id...
so the result is the following:
<option value="0" selected="selected">--</option>
<option value="1">D-3417</option>
<option value="2">D-1021</option>
<option value="3">D-4582</option>
<option value="4" selected="selected">D-FTSD</option>
<option value="5">D-5970</option>
But I want that the option value is my ID in the array like ID 10 in the last item, and not 5... Hope you understand what I mean.
I think the wrong line is this:
ng-options="aircraft.ident for aircraft in aircrafts"
But I dont understand how I fix this.
Thanks in advance,
Leif