如何在Angular 6中包含外部html文件和js文件? [英] How to include external html files and js file in Angular 6?

查看:208
本文介绍了如何在Angular 6中包含外部html文件和js文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Angular 6项目中包含一些html文件并在某些外部js文件中使用函数. 如何在Angular 6中包含外部html文件和js文件?

I want to include some html files and use functions in some external js files in my Angular 6 project. How can I include external html file and js file in Angular 6?

推荐答案

您可以将这些文件放在src/assets文件夹下,并在angular.json中指定路径.意思是,您可以将文件包含在src/assets/htmlsrc/assets/js文件夹下.

You can place those files under src/assets folder and specify the path in angular.json. Meaning, you can keep the files to be included under src/assets/html and src/assets/js folders.

angular.json配置,例如:

"build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/browser",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "progress": false,
            "showCircularDependencies": true,
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico",
              "src/robots.txt",
              "src/sitemap.xml"
            ],
            "styles": [
              "src/styles.css",
              "src/assets/css/home-style-min.css",
              "src/assets/css/prism-min.css"
            ],

放置在此处的所有文件都将在构建时选择.

All the files placed there will be picked at build time.

这篇关于如何在Angular 6中包含外部html文件和js文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆