Pregunta

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.

¿Fue útil?

Solución

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

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

Demo

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top