ng-bootstrap不显示工具提示 [英] ng-bootstrap not displaying tooltip
问题描述
我想显示一个工具提示.我去了ng-bootstrap并集成了该代码.正在获取控制台错误.
I want to display a tooltip. I went to ng-bootstrap and integrated that code. Getting console error.
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中添加了这些行
Added these lines in app.module.ts
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
@NgModule({
imports: [
NgbModule
]
})
使用命令安装了ng-bootstrap
Installed ng-bootstrap using command
npm install --save @ng-bootstrap/ng-bootstrap
推荐答案
您应该导入NgbModule.forRoot()
而不是NgbModule
.
确切的方法对于根(顶层)而言会略有不同 模块,其最终应类似于(注意
NgbModule.forRoot()
):
The exact method will be slightly different for the root (top-level) module for which you should end up with the code similar to (notice
NgbModule.forRoot()
):
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
@NgModule({
declarations: [AppComponent, ...],
imports: [NgbModule.forRoot(), ...],
bootstrap: [AppComponent]
})
export class AppModule {
}
应用程序中的其他模块可以简单地导入NgbModule
:
Other modules in your application can simply import NgbModule
:
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
@NgModule({
declarations: [OtherComponent, ...],
imports: [NgbModule, ...]
})
export class OtherModule {
}
有关更多详细信息,请阅读:
For more details , please read :
https://ng-bootstrap.github.io/#/getting-started
这是工具提示的工作示例:
Here is the working example of tooltip :
http://plnkr.co/edit/AVylfgSqv5iLVi73LGz7?p=preview
请与您的代码进行比较.
Please compare your code with it.
这篇关于ng-bootstrap不显示工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!