문제

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