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?
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.
AngularJS Introduction. AngularJS is a JavaScript framework. It can be added to an HTML page with a <script> tag.
Add external JS files If you want include any js library in your angular application like as jquery, bootstrap etc.. You can use npm command for install this library. After installing this library add them in styles and scripts array in angular. json respectively css and 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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With