Reputation: 93
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:
And the tooltip I want to get is:
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
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
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