asafdav / ng-csv

Simple directive that turns arrays and objects into downloadable CSV files
MIT License
573 stars 215 forks source link

Lazy Loading Still Not working #99

Open spaeth21 opened 9 years ago

spaeth21 commented 9 years ago

File is being downloaded before data can be returned from the database.

asafdav commented 9 years ago

Can you please provide your implementation ? it's a bit hard to help you like this.

michelem09 commented 8 years ago

I have same problem, here is my code:

// HTML
<button type="button" class="btn btn-inverse" lazy-load="true" quote-strings="true" ng-csv="getReportData()" filename="report.csv" translate>Generate report</button>

// Controller
$scope.getReportData = function() {
    SalesGenerate.query({sort: sortQuery, datefrom: '2015-01-01', dateto: '2015-02-01'}).$promise.then(
        function(data) {
            return data;
        }
    );
};

// Service
.factory('SalesGenerate', ['$resource',
    function($resource) {
        return $resource('sales/generate', {},
        {
            'query': {
                method:'GET',
                isArray: false
            }
        });
    }
]);

What am I missing?