2

I was converting my html css js codes into angular. I couldnt add third party js script like isotope.pkgd.min.js. I put the js file in angular.json file under script section it doesnt load.

"scripts": [
          "node_modules/jquery/dist/jquery.min.js",
          "src/assets/js/classie.js",
          "src/assets/js/modernizr.custom.js",
          "src/assets/js/stepsForm.js",
          "src/assets/js/switch.js",
          "src/assets/js/isotope.pkgd.min.js"
        ]

I want to add custom js like bootstrap.min.js without using npm install bootstrap --save

1 Answer 1

0

You need to have a local copy of your js file, (install it by npm or not ... no one cares) and then include it in the scripts as you have shown in the question. That WORKS.

If you want to use a CDN (imort the js from an online source at client side), just include the CDN in the index.html of your application, as you would normally do if it was a non-angular project.

Edit: To use a global loaded js file in angular components/services etc., you need to declare it in the typescript files or otherwise you'll get error.

Sign up to request clarification or add additional context in comments.

7 Comments

I have local copy of js files in my assets/js folder. still it dont reflect when i do ng serve
Show us the file tree, it's probably a pathing issue, or a very complicated webpack problem. Did you use the cli to create the project?
i used cli to create project
in the browser debugger, can you go to sources, and see if a scripts.js is emitted, and if your scripts are there?
are u using the latest cli version?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.