Problem displaying a dynamic select list on Ionic app

I am trying to display a dynamic list of user vehicles on a select dropdown component on an ionic app.

BUT

I cant seem to get all vehicles in the list, its appears to be overwriting them, leaving the last one only.

My list of vehicles from an external database via an api are held in:

$scope.vehicles (this variable is populated with the correct data)

The select component has the following properties:

ng-model: viewData.vehicles
ng-options: vehicles.id as vehicles.reg for vehicles in viewData.vehicleOptions

Within the service response that returns the vehicle data, I have the following code, but when I try the select in the app, only 1 vehicle reg is in the list, but I know there is more?



var vehicleOp = [];
var i=0;
$.each($scope.Vehicles, function( key, value ) {
vehicleOp['id']=i;
vehicleOp["reg"]=value.reg;
i++;
});

$scope.viewData = {
vehicles: 0,
vehicleOptions: [vehicleOp]
};

1 person has
this problem
+1
Reply