角度DOM中的StaticInjectorError

时间:2018-12-30 08:29:21

标签: angular

当我在Angular中使用表格元素时,有时会在浏览器的控制台中向我显示此错误 有什么问题?
我该如何解决?
角度HTML:

<table class="table table-striped table-hover table-bordered table-condensed  ">
  <thead>
    <tr class="tr-bottom-color-orrange">

      <th class="text-center">name</th>

    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let item of listItem">

      <td class="text-left">
        {{ item.name }}
      </td>      
    </tr>

  </tbody>
</table>  

错误:

ERROR Error: StaticInjectorError(AppModule)[TableDirective -> ColumnResizingService]: 
  StaticInjectorError(Platform: core)[TableDirective -> ColumnResizingService]: 
    NullInjectorError: No provider for ColumnResizingService!
    at _NullInjector.get (core.js:1002)
    at resolveToken (core.js:1300)
    at tryResolveToken (core.js:1242)
    at StaticInjector.get (core.js:1110)
    at resolveToken (core.js:1300)
    at tryResolveToken (core.js:1242)
    at StaticInjector.get (core.js:1110)
    at resolveNgModuleDep (core.js:10854)
    at NgModuleRef_.get (core.js:12087)
    at resolveNgModuleDep (core.js:10854)

我正在使用延迟加载模块 ContractModule:

@NgModule({
  imports: [
    SharedModule,
    KendoSharedModule,
    SmartadminModule,
    SmartadminValidationModule,
    PaginationModule.forRoot(),
    DpDatePickerModule,
    NgxMaskModule.forRoot(),
    SmartadminWizardsModule,
    ContractRoutingModule,
  ],
  providers: [ContractResolverService],
  declarations: [AddContractComponent, ListContractComponent, AddWarrantyComponent]
})
export class ContractModule { }

2 个答案:

答案 0 :(得分:0)

面对相同的问题,发现它是由从Kendo导入“ SharedModule”引起的。

答案 1 :(得分:0)

ColumnResizingService提供者中添加AppModule