简体   繁体   中英

How to include popper.js and bootstrap.js in angular project

I am using angular with openlayers and I am following the example posted below in the link:

        https://openlayers.org/en/latest/examples/overlay.html

the aforementioned link provide the following information in order to work with the popover:

Things to know when using the popover plugin:
Popovers rely on the 3rd party library Popper.js for positioning. You must include popper.min.js before bootstrap.js or use bootstrap.bundle.min.js / bootstrap.bundle.js which contains Popper.js in order for popovers to work!

please let me know how to include

popper.js 

and

bootstrap.js 

so i can work with the popover function and get it working.

image :

在此处输入图像描述

You can add node_modules/dist/css/boostrap.min.css in styles under the build section of angular.json file BEFORE src/styles.css . You can download the bootstrap from the npm package npm install bootstrap

In order to work with the pop ups you can add the bundle file of bootstrap node_modules/bootstrap/dist/js/bootstrap.bundle.min.js in the scripts under the build section of the same file.

EDIT: You have to download JQuery and add it to your scripts section as well.

for external JavaScript or any file that you want to implement on angular. you have to set path for that files on angular.json file

angular.json

在此处输入图像描述

for angular older version need set path on .angular.cli.json

Note :- after changes on angular.json file, you have to recompile or restart project.

you can import files into index.html file. 在此处输入图像描述

Just use npm to install:-

[propper]: > https://www.npmjs.com/package/propper

npm i propper --save

[bootstrap]: > https://www.npmjs.com/package/bootstrap

npm i bootstrap --save

There are some step that you have to follow.

-1. Install Jquery like npm instll jquery -save
-2. Install latest bootStrap npm install bootstrap@4.3.1 --save
-3. Install Popper js like npm install popper.js --save

And then add styles and scripts into angular.json file like在此处输入图像描述

========================================================================

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM