我有一個用戶添加示例數據的情況,如圖所示。我怎樣才能添加刪除按鈕,只刪除特定的樣本。從圖中,我想「刪除樣品1" 刪除樣品1個記錄。angularjs ng-repeater動態刪除數據
感謝
代碼觸發時添加樣品按鈕被點擊
$ scope.addSample =功能( ){
$scope.partdetails = [
{
"sampleseq": 0,
"sampleid": 1,
"attribute": "Height",
"measureunit": "Centimeter",
"actualvalue": null,
"lowerspec": 1.23,
"upperspec": 3.23,
"notes": null
},
{
"sampleseq": 0,
"sampleid": 2,
"attribute": "Diameter",
"measureunit": "Inches",
"actualvalue": null,
"lowerspec": 1.23,
"upperspec": 3.23,
"notes": null
}
];
$scope.partdetails[0].sampleseq = $scope.sampleCount;
$scope.partdetails[1].sampleseq = $scope.sampleCount;
$scope.partdetailsList.push($scope.partdetails[0]);
$scope.partdetailsList.push($scope.partdetails[1]);
$scope.sampleCount += 1;
}
請包含數據結構的示例和視圖的HTML。 – georgeawg
你想在行或表頂部添加刪除按鈕的位置?當用戶點擊delete-1時,你想刪除所有ID爲1的樣本?那是對的嗎?基本的例子是在這裏http://jsfiddle.net/crrypdLj/1/ – user3249448
當我說樣本1,這意味着前兩個頂部的行。只有這些行需要刪除,因爲它們屬於樣本1。不是所有的行。不幸的是,jsfiddle鏈接一次只刪除一行。 – bp581