I'm using AngularJS and ngGrid to display some letters in a grid.
http://plnkr.co/edit/SDr51bjiIW7EmP26b5w2
There's a column "name" that displays letter "a" through "e".
When I click on "name" it can sort the letters ascending and descending.
However, when the letters are descending, such "e" is first in the column and "a" is the last one, and I click on the "Remove First Entry" button, the letter "e" isn't remove. "a" and "b" are removed and another "e" is added to the list.
The list then is like this: e, e, d, c
Instead of: e, d, c, b
This is the code in to remove in main.js that starts the AngularJS app:
var app = angular.module('myApp', ['ngGrid']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [{name: "a"}, {name: "b"}, {name: "c"},{name: "d"}, {name: "e"}];
$scope.gridOptions = {data: 'myData'};
$scope.remove = function(){
$scope.myData.splice(0,1);
};
});
The issue is not present in ngGrid version 1.9.0.
Here's an Plunker using the older ngGrid version:
http://plnkr.co/edit/EeQtkFTiEa5uCBALm6A0
Once the column sorts the letters in a descending order, the button removes the first item in the array without adding letters back into the grid.