将 ag-grid 从共享模块导出到延迟加载模块给出错误

0 module lazy-loading angular

我创建了共享模块,我在其中导入了 angular ag - grid。所以,按照股份公司-网的办公场所,我们必须写AgGridModule.withComponents([])imports

但是我也必须导出它,因为我想将此导出用作我的延迟加载模块之一中的导入,而不是直接在appModule.

但是AgGridModule.withComponents([])从共享模块导出给了我错误。

共享模块.ts

import { AgGridModule } from 'ag-grid-angular';

imports: [
  AgGridModule.withComponents([])
]

enter code here`enter code here`

exports: [
  AgGridModule.withComponents([])    // this export is giving error
]

Run Code Online (Sandbox Code Playgroud)

错误描述:

Type 'ModuleWithProviders<any>' is not assignable to type 'any[] | Type<any>'.
Type 'ModuleWithProviders<any>' is missing the following properties
  from type 'Type<any>': apply, call, bind, prototype, and 5 more
Run Code Online (Sandbox Code Playgroud)

小智 7

您以错误的方式导出它。仅出口AgGridModule。您的代码将如下所示。

共享模块.ts

import { AgGridModule } from 'ag-grid-angular';

imports: [
  AgGridModule.withComponents([])
],
exports: [
  AgGridModule    // without withComponents([])
]
Run Code Online (Sandbox Code Playgroud)