Henriques Henriques - 1 year ago 74
jQuery Question

Push the values returned from a service in to an array using AngularJS

my service returns data from DB, now i want to push particular values from that data in to an array using AngularJS.

var prodData = make a call to the service.

var versionsArray = [];

The data returned from the service looks similar format


Now I want to push the values of the field "Versions":[4,5,6] in to an array called
, so that later I can bind that array to a drop-down and display the versions in the drop-down.

I wanted to something in the below way

id: prodData.Versions,
value: prodData.Versions

How do I retrieve those values an push them in to an array ?

Answer Source

well, Here how you can do it,

angular.forEach(prodData.Versions, function(version) {

I hope it helps you.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download