使用angular-ui-grid渲染网格数据时出现“ TypeError:i18nService.getSafeText不是函数”

时间:2019-06-23 22:21:47

标签: angularjs translation angular-ui angular-ui-grid

我已经在应用程序的模块导入文件中导入了df %>% group_by(birdID, site, rleid = rleid(site)) %>% summarise(min_ts = min(ts), max_ts = max(ts), days = difftime(max_ts, min_ts, units = "days")) %>% ungroup() %>% select(-rleid) %>% arrange(birdID, min_ts) 模块: ui-grid

在同一文件中添加了此导入的模块:

import 'angular-ui-grid/ui-grid.core';

在使用网格的视图控制器中,我设置了gridOptions:

const app = angular
  .module('app', [
    uiRouter,
    uiBootstrap,
    'ui.bootstrap.datetimepicker',
    'ui.grid',
    [...]
    ])

并在视图中设置网格元素:

this.gridOptions = {
  columnDefs: [
    {name: "Account", field: "accountNumber", enableCellEdit: false},
    {name: "dateFrom", field: "dateFrom", enableCellEdit: false},
    {name: "dateTo", field: "dateTo", enableCellEdit: false},
    {name: "operationsType", field: "operationType", enableCellEdit: false},
    {name: "someId", field: "someId", enableCellEdit: false}
  ]
};
[...]
const jsonObj = this.XLSX.utils.sheet_to_json(sheetObj, {header: ["accountNumber", "dateFrom", "dateTo", "operationType", "someId"]});
this.gridOptions.data = jsonObj;

但是在渲染网格时,控制台出现错误:

<div ng-if="vm.gridOptions.data" id="grid1" ui-grid="vm.gridOptions"
     class="grid col-xs-12">
</div>

但是该函数位于TypeError: i18nService.getSafeText is not a function at Object.link (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:4815:1), <anonymous>:2158:28) at eval (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:2394:1), <anonymous>:1247:18) at eval (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:2394:1), <anonymous>:9928:44) at invokeLinkFn (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:2394:1), <anonymous>:9934:9) at nodeLinkFn (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:2394:1), <anonymous>:9335:11) at eval (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:2394:1), <anonymous>:9673:13) at processQueue (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:2394:1), <anonymous>:16383:28) at eval (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:2394:1), <anonymous>:16399:27) at Scope.$eval (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:2394:1), <anonymous>:17682:28) at Scope.$digest (eval at <anonymous> (http://localhost:3000/vendor.bundle.js?97065532baea04c9b656:2394:1), <anonymous>:17495:31) <div ui-grid-menu="" menu-items="menuItems" col="col" class="ng-isolate-scope"> ui-grid.core.jsui-grid.core.min.jsui-grid.js中:

ui-grid.min.js

我不知道这是怎么回事。 有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

我发现了问题-我已经在使用自己的自定义i18nService,其名称与在angular-ui-grid中使用的i18n自定义服务相同。

必须重命名其中之一,问题消失了。

例如,我将整个angular-ui-grid软件包复制到本地应用程序供应商文件夹,并将ui-grid i18nService重命名为其他名称。

现在可以正常工作了。