Select values of a column in an object json then convert it to array AngularJs -


this object want select value of quantity , type don't know how if have make matrix place every value in martix cell begginer in angularjs , thank

[     {         id: 15,         nom: "azerty",         type: "azerty",         quantity: 456,         prix: 25296     },     {         id: 21,         nom: "sdqs",         type: "qsdqsd",         quantity: 102,         prix: 52     } ] 

try this

var x = [     {         id: 15,         nom: "azerty",         type: "azerty",         quantity: 456,         prix: 25296     },     {         id: 21,         nom: "sdqs",         type: "qsdqsd",         quantity: 102,         prix: 52     } ];  var type = []; var quantity = [];  x.foreach(function(item, index) {     type.push(item.type)     quantity.push(item.quantity)     if(index == x.length-1){         console.log("type: ",type);    //type: ['azerty','qsdqsd']         console.log("quantity: ",quantity);    // quantity : [456,102]     } })  // once foreach done you'll have type=[azerty,qsdqsd]  , quantity = [456,102] 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -