1

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!

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! I added the data-toggle attribute on Button element, but the problem remained (I updated the question). Do you have another idea? I use bootstrap V4
For Angular (not angular js) the best solution is ngx-bootstrap. It's simple to use and compatible with bootstrap markup and you could use v4 or v3. Using Jquery with Angular cause performance issues and not recommended.
1

You've mixed bootstrap v4 and v5.

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

1 Comment

You're right! Thanks! I adapted the two pieces of code to fit bootstrap v4.6, but the problem still remained. (I updated the question). Do you have an idea for another reason?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.