"TypeError: i18nService.getSafeText is not a function" when rendering data for grid using angular-ui-grid

"TypeError: i18nService.getSafeText is not a function" when rendering data for grid using angular-ui-grid

我已经在我的应用程序的模块导入文件中导入了 ui-grid 模块: import 'angular-ui-grid/ui-grid.core';

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

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

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

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.jsui-grid.min.js中:

getSafeText: function (path, lang) {
          var language = lang || service.getCurrentLang(),
            trans = langCache.get(language),
            missing = i18nConstants.MISSING + path,
            getter = $parse(path);

          if (!trans) {
            return missing;
          }

          return getter(trans) || missing;
        },

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

我发现了问题 - 我已经在使用我自己的自定义 i18nService,其名称与 angular-ui-grid.

中使用的 i18n 自定义服务相同

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

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

现在可以正常使用了。