Henriques Henriques - 3 months ago 6x
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 ?


well, Here how you can do it,

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

I hope it helps you.