scan4jobs

How to reset ng-repeat block after reordering some of it's elements?

Answered
0
0

I have an ng-repeat which uses an array as it’s data. Now from UI, I reorder the elements using drag and drop. I have a cancel button which should reset ng-repeat so that the ordering of elements gets back according to the order of the array. I don’t know how to do that. Is there any way to achieve that from angularjs or using jquery?

  • You must to post comments
Good Answer
1
0

One way would be changing the your $scope variable. By doing the following, you preserved your array order and trigger ng-repeat to rerender.

$scope.reset = function(){

    // $scope.data is the variable that holds the array in ng repeat
    $scope.data =  angular.copy($scope.data)

}
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website