工具提示未显示在ng-bootstrap中

时间:2019-02-12 14:15:00

标签: bootstrap-4 angular5 ng-bootstrap

我正在尝试将ng-bootstrap(1.1.0)与Angular(5.2.0)和bootstrap(4.0)一起使用。尽管我已经导入了所有特定的模块,但是无法显示工具提示。下面是我的代码:

app.module.ts:

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

@NgModule({
declarations: [AppComponent, ...],
imports: [NgbModule.forRoot(), ...],
bootstrap: [AppComponent]
})
export class AppModule {
}

component.html:

<ul class="navbar-nav">
  <li>
   <button type="button" class="btn btn-outline-secondary mr-2" 
     placement="bottom" ngbTooltip="Tooltip text">Hover over me
   </button>
  </li>
</ul>

任何人都可以帮助我知道我在做什么错。

1 个答案:

答案 0 :(得分:0)

您需要将BrowserModuleNgModule添加到您的应用中。

您的app.module.ts的外观如下:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

import { AppComponent } from './app.component';

@NgModule({
  imports:      [ BrowserModule, NgbModule.forRoot() ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }