I am using Angular Datatable with ng-repeat, where all columns can be sorted. After sorting, I want the scope variable should be changed.. Can it be achieved?
simple example is below: In my case I'm using array of JSON
objects
$scope.names = ['XYZ', 'DEF', 'ABC', 'IJK'];
After datatable sorting applied on name field, the value of name filed should be changed to the following:
$scope.names = ['ABC', 'DEF', 'IJK', 'XYZ'];
The below code is working... Thanks @davidkonrad for the hint on dtInstance
var sortedTableArray = [];
var sortedJSON = []
DTInstances.getList().then(function(dtInstances) {
sortedTableArray.push(dtInstances.viewTable.DataTable.context[0].aiDisplay)
sortedJSON = _.sortBy(unsortedList, function(obj){
return _.indexOf(_.toArray(sortedTableArray[0]), obj.id);
});