ng-bootstrap

时间:2017-12-26 04:54:41

标签: angular ng-bootstrap

需要在我的项目中实施评级系统,所以我尝试使用ng-bootstrap模块并使用下面的代码:

<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 个答案:

答案 0 :(得分:2)

确保您已在app.module.ts

中导入** NgbModule **
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

imports:      [ 
  NgbModule.forRoot(),
]