Home > Net >  angular how to add internal js file to index.html
angular how to add internal js file to index.html

Time:02-01

HOw i can insert custom js file in index.html? Always get error 404 https://i.stack.imgur.com/e6EWe.png

But if add custom.js works well https://i.stack.imgur.com/QWsPv.png

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

CodePudding user response:

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>

CodePudding user response:

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"
        ]
      }
    }
  }
  •  Tags:  
  • Related