我想显示工具提示。我去了ng-bootstrap并集成了该代码。出现控制台错误。
core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: No provider for
NgbTooltipConfig!
Error: No provider for NgbTooltipConfig!
at injectionError (core.es5.js:1169)
at noProviderError (core.es5.js:1207)
at ReflectiveInjector_._throwOrNull (core.es5.js:2649)
at ReflectiveInjector_._getByKeyDefault (core.es5.js:2688)
at ReflectiveInjector_._getByKey (core.es5.js:2620)
at ReflectiveInjector_.get (core.es5.js:2489)
at resolveNgModuleDep (core.es5.js:9492)
at NgModuleRef_.get (core.es5.js:10562)
at resolveDep (core.es5.js:11050)
at createClass (core.es5.js:10920)
在app.module.ts
中添加了这些行import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
@NgModule({
imports: [
NgbModule
]
})
使用命令
安装ng-bootstrapnpm install --save @ng-bootstrap/ng-bootstrap
答案 0 :(得分:2)
您应该导入NgbModule.forRoot()
而不是NgbModule
。
根(顶级)的确切方法会略有不同 模块,你应该得到类似的代码(通知
NgbModule.forRoot()
):import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; @NgModule({ declarations: [AppComponent, ...], imports: [NgbModule.forRoot(), ...], bootstrap: [AppComponent] }) export class AppModule { }
您应用中的其他模块只需导入
NgbModule
:import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; @NgModule({ declarations: [OtherComponent, ...], imports: [NgbModule, ...] }) export class OtherModule { }
有关详细信息,请阅读:
https://ng-bootstrap.github.io/#/getting-started
以下是工具提示的工作示例:
http://plnkr.co/edit/AVylfgSqv5iLVi73LGz7?p=preview
请将您的代码与之比较。
答案 1 :(得分:0)
将NgbTooltipConfig添加到提供程序
@NgModule({
imports: [
NgbModule
],
providers: [
NgbTooltipConfig
]
})
并将此CSS添加到您的style.css
.tooltip{
opacity:1!important;
}