ng-bootstrap - ngbtooltip not working with [(ngModel)]

好久不见. 提交于 2020-01-03 19:33:08

问题


I'm new to angular 4 and bootstrap beta 2 and trying to use ngbtooltip to show tool tip text. Tooltip on the label is working fine when only input does not have [(ngModel)]. As soon as I used [(ngModel)] in input text control, tooltip is showing only for the first label and other labels does not. In the below code, if I remove ngModel, all labels tooltips are shown as expected.

<div class="col-lg-12 col-md-12 col-sm-12 ">
  <div class="col-lg-12 col-md-12 col-sm-12  container accordion" id="accordion">
    <div id="collapseDealSummary" class="col-lg-12 col-md-12 col-sm-12  card-block collapse show row">
      <div class="col-lg-12 col-md-12 col-sm-12 card-body row">
        <div class="col-lg-6 col-md-12 col-sm-12">
          <div class="col-lg-12 col-md-12 col-sm-12">
            <div class="row">
              <div class="col-lg-6 col-md-6 col-sm-6 form-group pull-left mx-0 px-1" placement="top" triggers="hover" ngbTooltip="Tooltip on for label 1">
                <label>label 1<span>*</span></label>
                <input type="text" class="form-control" id="txtid" name="txtid" [(ngModel)]="Label1Value" />
              </div>
              <div class="col-lg-6 col-md-6 col-sm-6 form-group pull-left mx-0 px-1" placement="top" triggers="hover" ngbTooltip="Tooltip on for label 2">
                <label>label 2<span>*</span></label>
              </div>
              <div class="col-lg-6 col-md-6 col-sm-6 form-group pull-left mx-0 px-1">
                <label placement="top" triggers="hover" ngbTooltip="Tooltip on for label 3">label 3<span>*</span></label>
              </div>
              <div class="col-lg-6 col-md-6 col-sm-6 form-group pull-left mx-0 px-1">
                <label placement="top" triggers="hover" ngbTooltip="Tooltip on for label 4">rlabel 4<span>*</span></label>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Any idea why tooltip is not working correctly along with [(ngModel)]? Thanks


回答1:


I think what you are trying to do is this:

<button type="button" class="btn btn-outline-secondary" [ngbTooltip]="tipContent">My button</button>

The model variable has to be linked to [ngbTooltip].



来源:https://stackoverflow.com/questions/47776882/ng-bootstrap-ngbtooltip-not-working-with-ngmodel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!