We are using $http to get array of columns and then bind it to dtColumns object of angular datatable.
But before the bind code is called, 'aDatasort is not defined ' error occurs.
Below is the html code
<table datatable="" dt-options="showCase.dtOptions" class="row-border hover"></table>
Below is the Controller code
($scope.col is the array of columns which are build using $http)
vm.dtOptions = DTOptionsBuilder.newOptions()
.withOption('ajax', {
// Either you specify the AjaxDataProp here
// dataSrc: 'data',
url: ../api/Page/data',
type: 'POST',
dataSrc: function(json) {
console.log(json);
var names = json.columns;
return json.data;
},
})
// or here
.withDataProp('data')
.withOption('processing', true)
.withOption('serverSide', true)
.withDisplayLength(10)
.withPaginationType('full_numbers');
vm.dtColumns = $scope.col;