asafdav / ng-csv

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

Added handling when a function is passed as parameter. #101

Closed aagbayani closed 8 years ago

aagbayani commented 9 years ago

Had an issue when I passed a function to ng-csv the change I did fixed it.

-- Button

    <button type="button" class="btn btn-primary" id="exportCSVButton" data-ng-csv="getReportItems" data- lazy-load="true" data-filename="csvFilename" data-csv-header='csvHeaders'>

-- Controller Js

    $scope.getReportItems = getReportItems;

    function getReportItems() {
        return ReportItemService.findReportItems($scope);
    }

-- Service Js

    function findReportItems(scope) {
        var deferred = $q.defer();

    $http({
        method: 'POST', 
        url: url,
        data: scope.reportEntity
    }). success(function(data) {
        //handling of data                    
    }
    deferred.resolve(result);
    });
        return deferred.promise;
    }
asafdav commented 8 years ago

Hi, did you try passing it that way ?

<button data-ng-csv="getReportItems()">...
aagbayani commented 8 years ago

Thanks, It is working now. All the time I wasted on trying to fix it, and the fix is so simple.

----- Original Message ----- From: "Asaf David" notifications@github.com To: "asafdav/ng-csv" ng-csv@noreply.github.com Cc: "aagbayani" aagbayani@exist.com Sent: Sunday, August 9, 2015 3:43:58 AM Subject: Re: [ng-csv] Added handling when a function is passed as parameter. (#101)

Hi, did you try passing it that way ?

<button data-ng-csv="getReportItems()">...

Reply to this email directly or view it on GitHub: https://github.com/asafdav/ng-csv/pull/101#issuecomment-129040744

asafdav commented 8 years ago

No worries :)