我在 Controller 中创建了一个 dateTime
函数,如下所示:
$scope.getDatetime = function() {
return (new Date()).toLocaleFormat("%A, %B %e, %Y") + "name.csv" ;
};
我正在使用 gridOptions
如下
$scope.gridOptions = {
exporterCsvFilename: 'getDatetime()',
exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
columnDefs: [
{ field: 'Field1' },
{ field: 'Field1' }
]
};
使用上述语法,将下载名为 getDatetime().csv
的文件,而不是显示实际日期
最佳答案
不要给出单引号,如果给出单引号,它将被视为字符串
$scope.gridOptions = {
exporterCsvFilename:$scope.getDatetime(),//call the function
exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
columnDefs: [
{ field: 'Field1' },
{ field: 'Field1' }
]
};
关于javascript - 在 Angular gridOptions 中调用另一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55877708/