代码之家  ›  专栏  ›  技术社区  ›  Joseph Charles

ng引导中的StaticInjectionError

  •  0
  • Joseph Charles  · 技术社区  · 7 年前

    需要在我的项目中实施评级系统,因此我尝试使用ng引导模块,并使用以下代码:

    <ngb-rating [(rate)]="currentRate"></ngb-rating>
    

    但在浏览器上运行时会出错:

    ng:///AppModule/SearchResultsComponent.ngfactory.js:55 ERROR Error: StaticInjectorError[NgbRatingConfig]: 
      StaticInjectorError[NgbRatingConfig]: 
        NullInjectorError: No provider for NgbRatingConfig!
        at _NullInjector.get (webpack-internal:///../../../core/esm5/core.js:1190)
        at resolveToken (webpack-internal:///../../../core/esm5/core.js:1478)
        at tryResolveToken (webpack-internal:///../../../core/esm5/core.js:1420)
        at StaticInjector.get (webpack-internal:///../../../core/esm5/core.js:1291)
        at resolveToken (webpack-internal:///../../../core/esm5/core.js:1478)
        at tryResolveToken (webpack-internal:///../../../core/esm5/core.js:1420)
        at StaticInjector.get (webpack-internal:///../../../core/esm5/core.js:1291)
        at resolveNgModuleDep (webpack-internal:///../../../core/esm5/core.js:11075)
        at NgModuleRef_.get (webpack-internal:///../../../core/esm5/core.js:12307)
        at resolveDep (webpack-internal:///../../../core/esm5/core.js:12805)
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Sajeetharan    7 年前

    确保已导入** NgbModule **应用程序内。单元ts

    import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
    
    imports:      [ 
      NgbModule.forRoot(),
    ]