【问题标题】:Calling another function within Angular gridOptions在 Angular gridOptions 中调用另一个函数
【发布时间】:2019-04-27 05:57:22
【问题描述】:

我在控制器中创建了一个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,而不是显示实际日期

【问题讨论】:

标签: javascript angularjs model-view-controller angularjs-directive


【解决方案1】:

不要给单引号,如果给单引号它会被认为是一个字符串

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-27
    • 2018-07-10
    • 2019-02-17
    • 2016-12-21
    • 2019-02-24
    • 2017-03-07
    • 2019-09-17
    • 2013-12-17
    相关资源
    最近更新 更多