Alan Smith
Posts: 0
Joined: Tue Jun 10, 2014 4:59 pm

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?

pre

Code: Select all

     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] 
     }; 

/pre

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Problem displaying a dynamic select list on Ionic app

Hello Alan,

That code creates an array of arrays, instead of the simple array of vehicles.

Please change:prevehicleOptions: [vehicleOp]/pre to prevehicleOptions: vehicleOp/pre

Alan Smith
Posts: 0
Joined: Tue Jun 10, 2014 4:59 pm

Problem displaying a dynamic select list on Ionic app

Thanks for replying.

I have changed to above. but now I get nothing, the select is empty, no options!

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Problem displaying a dynamic select list on Ionic app

Please share (https://docs.appery.io/docs/teams-sha...) your app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and provide us with the following information:

1) App name
2) Test credentials if login functionality is implemented in your app
3) Detailed steps to reproduce the issue

Return to “Issues”