Reputation: 351
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?
Upvotes: 5
Views: 6872
Reputation: 1868
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
configuration like :
"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.
Upvotes: 4