javascript - angular js - missing : after property id -


i'm using angular js creating json, when tried make json shown below

$scope.newcolumns =[{"file 1":"file1.png"},{"file 1":"file2.png"}] 

i'm getting missing : after property id

my code given below

 $scope.newcolumns = [];     angular.foreach( $scope.datas, function(data){             $scope.newcolumns.push({data.id : data.value});     }); 

can please tell me solution this

i think need this,

var obj={}; obj[data.id]= data.value; $scope.newcolumns.push(obj); 

{data.id : data.value} not valied syntax data.id should name property cannot variable. if need have variable field names need above.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -