I created a directive for JQuery DataTables in AngularJS and it works with each data source types, except server-side processing. With the latter I get an error saying: TypeError: Cannot read property 'aDataSort' of undefined
.
I have the following code in the directive's link
function:
var buildTableFromServer = function() {
var table = $(el).find('table');
if (! $.fn.DataTable.isDataTable(table)) {
table.DataTable({
"processing": true,
"serverSide": true,
"ajax": scope.dataSource
});
}
}
The error stack I get points to the line where I call .DataTables()
(after some lines in DataTables JS file).
I checked and table
is found, scope.dataSource
is set (it's a URL string, the one used in the example). Moving the DT code outside of the if block does nothing either.
What could be the problem? If needed, I can provide more code, but I don't think any more would help.