以下是AngularJS Code.Here我将四个记录添加到" roleList "。但我想在" roleList "中添加N个记录。我怎样才能做到这一点。
$scope.roleList = [
{"companyName": "Company 01", "id":"1", "position": "CEO"},
{"companyName": "Company 02", "id":"2", "position": "Board of Director"},
{"companyName": "Company 01", "id":"1", "position": "CEO"},
{"companyName": "Company 02", "id":"2", "position": "Board of Director"}
];
答案 0 :(得分:1)
为什么不制作for
?
var limit=100;
var roleList=[];
for(var i=0;i<limit;i++){
roleList.push({
companyName:'some name',
id:i,
position:'some position'
});
}
$scope.roleList=roleList;