how can I import a js file in angular 6. I tried to implement a navbar and it contains js functions. thanks!!!
I Add my js file called nav.js
\"scripts
Angular 6 has a dedicated place to declare js files within the dedicated arrays of your angular.json, under
/projects/$(youProjectName)/architect/build/options/scripts[]
and
/projects/$(youProjectName)/architect/test/options/scripts[]
As an example:
npm install fast-levenshtein --save
will install a js library under node-modules
The path relative to the project of the js lib file is declared like this:
"scripts": [
"node_modules/fast-levenshtein/levenshtein.js"
]
Then declare in your component the variable(s) to use, either as described by the npm documentation or by @LuaXD