roberthovhannisyan / PhoneGap-Plugin-ListPicker

ListPicker Plugin for Cordova/PhoneGap (iOS and Android)
MIT License
35 stars 40 forks source link

How to populate dynamic content in the list picker #19

Open sankari123 opened 8 years ago

sankari123 commented 8 years ago

I have an array which is created at run time. I want to use this array as the list.

venue_array=(["NGS","NGS"],["VMl","VM"],["KGS","KGS"],["BVB","BVB"]);

var config = { title: "Select a Venue", items: venue_array, selectedValue: "NGS", doneButtonLabel: "Done", cancelButtonLabel: "Cancel" };

roberthovhannisyan commented 8 years ago

Hi @sankari123 , Consider using map() method to convert each item of venue_array to an object with required properties:

venue_array = venue_array.map(function(e) { 
  var result = {};  
  result['text'] = e[0]; // or e[1]
  result['value'] = e[1]; // or e[0]
  return result;
});
sankari123 commented 8 years ago

Thanks for yr reply. I tried your code. But I get this msg. [object Object],[object Object],[object Object],[object Object]