5

I am trying to create a popover in the Javascript of my Angular 12 project. I am using Boostrap v5.0.1. I can't seem to get rid of a name error when I am trying to create the popover:

 var exampleEl = document.getElementById(item.name + index);
 var tooltip = new bootstrap.Popover(exampleEl, {
    container: 'body',
    animation: true
 });

Typescript is telling me "Can't find name bootstrap".

I have added bootrap.js to my angular.json file:

"scripts": [
   "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
]

According to the docs, popper.js is included in the bundle file. I am not using jQuery and do not want to include it. I have not seen another post with a similar issue so I must be just overlooking something small. Any ideas?

bschmitty
  • 1,118
  • 3
  • 16
  • 46

1 Answers1

8

Posting this declaration at the top of the file worked:

declare var bootstrap: any;
bschmitty
  • 1,118
  • 3
  • 16
  • 46
  • 1
    I was experimenting with a bootstrap menu inside an angular component, and had this same error. adding this code under the import fixed it. – greg Dec 15 '21 at 01:16
  • Same for me @greg. Is there anything else to consider with this solution? – MikhailRatner May 23 '22 at 15:14