ngx-bootstrap工具提示未显示在angular2中

时间:2017-09-01 12:25:27

标签: angular tooltip ngx-bootstrap

我有一个angular-cli应用程序,需要包含按钮的工具提示 这是我的app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import {BenefitsManagementModule} from './benefits-management/benefits-management.module';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';
import { AuthService } from './auth/auth.service';
import {AppRoutingModule} from './app-routing.module';
import { TooltipModule } from 'ngx-bootstrap';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    BenefitsManagementModule,
    AppRoutingModule,
     TooltipModule.forRoot()
  ],
  providers: [
    AuthService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { };

这是我的按钮

的html

<button type="submit" [disabled]="!benefitScheduleForm.valid" class="btn btn-md btn-primary" style="float:left;">Add</button> <button type="button" tooltip="mytooltip" class="btn btn-md btn-primary" style="float:right;" (click)="cancel()">Cancel</button> </div>

有人可以帮帮我吗?

2 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。 解决方案是将opacity属性设置为100。

&#13;
&#13;
.tooltip {
  opacity: 100;
}
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您使用的是什么版本的Angular?

您在Chrome / ng serve控制台中看到了什么内容吗?

这可能是因为Angular版本太旧了。确保使用Angular(至少4.x)和ngx-bootstrap的最新版本。

虽然一个plunkr确实有帮助,但我发现你发布的代码没有任何问题。 cancel()方法实际上是否存在于您的组件中?

最佳

相关问题