Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 5 Popover Error - Cannot find name 'bootstrap'

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?

like image 228
bschmitty Avatar asked Jun 18 '26 12:06

bschmitty


1 Answers

Posting this declaration at the top of the file worked:

declare var bootstrap: any;
like image 59
bschmitty Avatar answered Jun 20 '26 03:06

bschmitty