2017-02-24 58 views
2

http://plnkr.co/edit/WFONNlAEIeN8K9DEJCqV?p=catalogue斜面删除 - 角

我装盘到删除/移除仅所选择的行 但没有成功。

remove函数

$scope.removeTrainee = function(trainee){ 
    var removeTrainee = $scope.trainees.indexOf(trainee); 
    $scope.trainees.splice(removeTrainee, 1); 
}; 

select函数

$scope.selectedRow = null; // initialize our variable to null 
    $scope.setClickedRow = function(index){ //function that sets the value of selectedRow to current index 
    $scope.selectedRow = index; 
    }; 

试图实现在selectedrow NG-IF或& &标志 什么都没有

删除NG点击功能起作用,但不适用于选定的。 帮助,请

回答

0

采取选择你$scope.selectedRow所以你funcion应该是这样的一行:

$scope.removeTrainee = function(trainee){ 
    var removeTrainee = $scope.trainees.indexOf(trainee); 
    $scope.trainees.splice($scope.selectedRow, 1); 
}; 

无论如何,我建议你inplement删除功能以另一种方式,更直观,例如添加类在点击它之后选中的行或者添加一个带有复选框的新行,以知道选择了哪一行。

而且你还可以你的精神加强和改进功能addTrainee:

$scope.addTrainee = function(){ 
    $scope.trainees.push(
    $scope.newTreinee 
); 
    $scope.newTreinee = {}; 
}; 

希望这解决方案帮助您。

+0

http://plnkr.co/edit/95naBtiya9FXV7hWGPXM?p=preview – Josito

+0

惊喜!工作,谢谢你! – torresito