我有这样的物体 $scope.releases = [{name : "All Stage",active:true}];
$scope.releases = [{name : "All Stage",active:true}];
我需要附加更多数据
[ {name : "Development",active:false}, {name : "Production",active:false}, {name : "Staging",active:false} ]
所以最终数据应该像这样
[ {name : "All Stage",active:true} {name : "Development",active:false}, {name : "Production",active:false}, {name : "Staging",active:false} ]
我尝试了以下代码。但这不是附加的。
app.controller('MainCtrl', function($scope) { // I am having an object like this $scope.releases = [{name : "All Stage",active:true}]; // I need to appned some more data to it $scope.releases = [ {name : "Development",active:false}, {name : "Production",active:false}, {name : "Staging",active:false} ] });
Pluker链接:http ://plnkr.co/edit/gist:3510140
$scope.releases = [{name : "All Stage",active:true}]; // Concatenate the new array onto the original $scope.releases = $scope.releases.concat([ {name : "Development",active:false}, {name : "Production",active:false}, {name : "Staging",active:false} ]);