Add .js scripts in Angular 2 project

前端 未结 3 651
慢半拍i
慢半拍i 2021-01-04 09:22

I am building a web app with Angular 2 framework and I want to use an external template (https://freehtml5.co/preview/?item=splash-free-html5-bootstrap-template-for-any-webs

3条回答
  •  孤城傲影
    2021-01-04 09:43

    If you're using the Angular CLI you can include .js files from your node_modules in your .angular-cli.json.

    Right under the the styles array and above the environmentSource you should see the scripts array. I've included a little bit (I've truncated it) of the JSON as reference for you.

    {
      "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico"
          ],
          "index": "index.html",
          "main": "main.ts",
          "styles": [
            "styles.scss"
          ],
          "scripts": [
            "../node_modules/hammerjs/hammer.min.js"
          ],
          "environmentSource": "environments/environment.ts",
          "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts"
          }
        }
      ]
    }
    

提交回复
热议问题