数据获取
yellow
我正在做的是
data = {
sample1//object{
results :{
name:'name1',
label:'label1'
},
{
name:'name1',
label:'label1'
}
}
sample2//object
results :{
name:'name1',
label:'label1'
},
{
name:'name1',
label:'label1'
}
}
但我想添加关键名称,例如
for ( var name in data )
{
$scope.model.datalist.push(data[name]);
}
console.log($scope.model.datalist) - >
result : results :{
name:'name1',
label:'label1'
}, (all reslults)
请指导如何做到这一点。其中sample1和sample2是动态的,它也可能是主要对象的其他名称
答案 0 :(得分:1)
angular.forEach(arrayOfObjects, function(singleObject){
singleObject.dynamicKey = dynamicValue;
});