Question

I want by clicking in the "Add row" button the new row will be on the top table. I have this basic example.

I tried to add a filter to the function bellow, but I got hte same result.

// add user
$scope.addUser = function() {
  $scope.inserted = {
    id: $scope.users.length+1,
    name: '',
    status: null,
    group: null 
  };
  $scope.users.push($scope.inserted);
};

Thank you for help.

Was it helpful?

Solution

Use unshift instead of push so that the item is added to the start of the array:

    $scope.users.unshift($scope.inserted);

Demo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top