I want to use some external jQuery libraries in my Angular project.
I added these libraries inside index.html
file, but they are not working. I also added my .js
files in angular.json
, but the problem still exists. I add libraries like this:
<!-- CUSTOM JS --> <script src="assets/js/jquery.app.js"></script>
Actually the code in this js file is not reachable. It seems Angular does not understand it to go and run that specific function in this file.
I expect a menu item shows its sub menus but the jQuery code does not work in Angular.
As you use Angular, you probably also use the angular/cli. In that case, just add your file in the angular.json
file like :
"scripts": [
"../node_modules/jquery/dist/jquery.js"
],
This will let angular import your external lib in the end bundle.
You will find more informations in the official documentation : https://github.com/angular/angular-cli/wiki/stories-global-scripts
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.