Sunny
Sunny

Reputation: 93

Problem with adding tooltip with bootstrap (Angular, ts)

I want to add a tooltip (with the help of bootstrap) to the site I am building (Angular, in ts).

I used the link: https://getbootstrap.com/docs/4.0/components/tooltips/

The problem:

The tooltip I created looks like this:

enter image description here

And the tooltip I want to get is:

enter image description here

My code:

componentName.component.ts:

  <button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">
    Tooltip on bottom
  </button>

index.html:

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
 

  <!-- For tooltips: -->
  <script>
    $(function () {
      $('[data-toggle="tooltip"]').tooltip()
    })
  </script>

The question: Do you have any idea where my mistake is? Thanks!

Upvotes: 1

Views: 947

Answers (2)

deelde
deelde

Reputation: 1591

You've mixed bootstrap v4 and v5.

The markup of your component is from bootstrap v5 and the javascript-code from bootstrap v4.

Upvotes: 1

Hassan Ghasemi
Hassan Ghasemi

Reputation: 151

I think you missed data-toggle attribute on Button element. And another important question is Did you import jquery inside Angular? Native Angular way for using bootstrap is ngx-bootstrap

Upvotes: 1

Related Questions