1019日重点: 用随机数给对象创造一个id, 辅助完成删除等操作
$scope.records = [];
function S4()
{
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
function newobj() {
var obj = {
"id":S4(),
"amount":$scope.amount,
"bounty":$scope.bounty
}
return obj;
}
$scope.records.push(newobj());
//新增一行
$scope.adddetails1 = function(){
console.log("添加")
$scope.records.push(newobj());
}
//删除一行,根据id来删除
$scope.deldetails1 = function(row){
for(var r in $scope.records){
if($scope.records[r].id==row.id)
{
$scope.records.splice(r,1);
}
}
console.log(row);
}
浙公网安备 33010602011771号