سؤال

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.

هل كانت مفيدة؟

المحلول

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

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

Demo

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top