Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


cancel edit in angular js using splice


cancel edit in angular js using splice  using -'javascript,angularjs'

I am using datagrid using data from listOfAttributes array. there is edit icon, on click on that again two buttons there.. save and cancel edit. I want if user click on cancel edit, updated data should be clear and previously data should again persist. I am using splice for add previous object, and delete current object at a same time but it doesn't work.

 $scope.edit = function(attribute) {
    angular.copy(attribute, $scope.copyAttr);
 }

$scope.save = function(attribute){
  // works fine;
}

 $scope.cancelEdit = function(attribute) { // doesn't work

    var indx = $scope.listOfAttributes.indexOf(attribute);

    $scope.listOfAttributes.splice(indx, 0, $scope.copyAttr);
    $scope.listOfAttributes.splice(indx,1);

}

    

asked Oct 13, 2015 by tejas lakhani
0 votes
3 views



Related Hot Questions



Government Jobs Opening


...