在两个Angular 2应用程序之间共享模块

时间:2018-04-05 15:31:06

标签: angular ag-grid-ng2

我的项目包含两个单独的Angular应用程序,它们必须共享一个模块。 它在App A中完美运行,但是当我从App B创建相对导入到A时,它会抛出StaticInjectorError

ERROR Error: StaticInjectorError(AppModule)[AgGridNg2 -> ComponentFactoryResolver]: 
  StaticInjectorError(Platform: core)[AgGridNg2 -> ComponentFactoryResolver]: 
    NullInjectorError: No provider for ComponentFactoryResolver!

我希望只更改App B中的导入路径,使其指向App A中的模块。

像这样: App A(这很好用):

import { GridModule } from './grid/grid.module';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    GridModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

App B:

import { GridModule } from '../../../qtgridview/src/app/grid/grid.module';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    GridModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

有问题的模块:

@NgModule({
  imports: [
    CommonModule,
    AgGridModule.withComponents([
      IconCellRendererComponent
    ])
  ],
  providers: [],
  declarations: [GridComponent, IconCellRendererComponent],
  exports: [GridComponent]
})
export class GridModule { }

这可能吗?我将如何以这种方式包含模块?提前致谢

0 个答案:

没有答案
相关问题