0

How can I insert a custom js file in index.html? Always get error 404 https://i.sstatic.net/e6EWe.png

But if add custom.js works well https://i.sstatic.net/QWsPv.png

I can't use node_modules because is very personal js (edited by me) Thanks!

1
  • The answer seems to be in your own screenshots..? What is different in those two paths? Commented Jan 29, 2022 at 21:05

2 Answers 2

2

Add external JS files:

If you want include any js library in your angular application

add them in scripts array in angular.json respectively .js You can see in build: { } object.

Here is an example of JSON data:

"architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        ...
        "scripts": [
          "src/assets/js/custom.js"
        ]
      }
    }
  }
Sign up to request clarification or add additional context in comments.

Comments

0

Correct path:

<script src="./assets/vendors/moment/moment-with-locales.min.js"></script>
<link href="./assets/vendors/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css" type="text/css" media="all" rel="stylesheet" />
<script src="./assets/vendors/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>

Comments

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.