【问题标题】:Exporting ag-grid from shared module to lazy loaded module giving error将 ag-grid 从共享模块导出到延迟加载模块给出错误
【发布时间】:2020-01-27 12:47:39
【问题描述】:

我创建了共享模块,我在其中导入了角度 ag - 网格。 因此,根据 ag - grid 的办公站点,我们必须在 imports 中写入 AgGridModule.withComponents([])

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

但是从共享模块中导出 AgGridModule.withComponents([]) 会出现错误。

shared.module.ts

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

imports: [
  AgGridModule.withComponents([])
]

enter code here`enter code here`

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

错误说明:

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

【问题讨论】:

    标签: angular module lazy-loading


    【解决方案1】:

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

    shared.module.ts

    import { AgGridModule } from 'ag-grid-angular';
    
    imports: [
      AgGridModule.withComponents([])
    ],
    exports: [
      AgGridModule    // without withComponents([])
    ]
    

    【讨论】:

      猜你喜欢
      • 2018-04-17
      • 2017-02-17
      • 2019-04-19
      • 2017-05-16
      • 2018-05-22
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      • 1970-01-01
      相关资源
      最近更新 更多