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
I suggest some workaround if you can grasp the functions within the script. So You either put them in your component.ts code as functions ,or if you can't/don't want to , you will just have to export/import them . for example
myscript.js
function a(){ ...}
function b(){...}
module.exports.a=a
module.exports.b=b
mycomponent.component.ts
..
import a from './path/../myscript.js';
import b from './path/../myscript.js';
..
constructor(){
...
a.a()
b.b()
...
}
ps:many times you will find function anonymous so you just have to rename them , for example
myscript.js
function(){..}();
will be
myscript.js
function myCustomName(){..};
module.exports.customName=myCustomName