0

I have created a dateTime function as below within my controller:

    $scope.getDatetime = function() {
        return (new Date()).toLocaleFormat("%A, %B %e, %Y") + "name.csv" ;
    };

I am using gridOptions as below

    $scope.gridOptions = {
        exporterCsvFilename: 'getDatetime()',
        exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
        columnDefs: [
            { field: 'Field1' },
            { field: 'Field1' }
        ]
    };

Using the above syntax, the file is downloading with name as getDatetime().csv instead of displaying the actual date

1
  • The non-standard Date.prototype.toLocaleFormat method is deprecated and shouldn't be used anymore. It uses a format string in the same format expected by the strftime() function in C. The function is no longer available in Firefox 58+. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… Commented Apr 27, 2019 at 11:50

1 Answer 1

1

Don't give single quotes, if you give single quotes it will consider as a string

$scope.gridOptions = {
            exporterCsvFilename:$scope.getDatetime(),//call the function
            exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
            columnDefs: [
                { field: 'Field1' },
                { field: 'Field1' }
            ]
        };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.