In AngularJS project I'm using Smart Table module and asafdav/ng-csv to export data from smart table to CSV.
I successfully export data from smart table to csv, but only from first page. I export data from $scope.displayedCollection
variable (the same as in st-table directive). In this variable is exacly the same data as in table, but only from first page. Do you know how can I export whole data (with sorting and filtering from smart table). I think that I should "plug in" to smart table module before splitting data to pages. But how?
I created my own directive for get access to data from table before pagination:
angular.module('smart-table')
.directive('stFilteredCollection', function () {
return {
restrict: 'A',
require: '^stTable',
scope: {
stFilteredCollection: '='
},
controller: 'stTableController',
link: function (scope, element, attr, ctrl) {
scope.$watch(function () {
return ctrl.getFilteredCollection();
}, function (newValue, oldValue) {
scope.stFilteredCollection = ctrl.getFilteredCollection();
});
}
};
});
To use it please add st-filtered-collection
attribute with name of variable which will be setting to data from table before pagination:
<table st-table="..." st-safe-src="..." st-filtered-collection="filteredCollection">
...
</table>
From now in controller you can use $scope.filteredCollection
variable.