I would like to insert a <script>...</script>
inside a .html
component in an Angular project and I was wondering how it can be done.
It seems like any Javascript I insert into this component is just ignored.
I would like to insert a <script>...</script>
inside a .html
component in an Angular project and I was wondering how it can be done.
It seems like any Javascript I insert into this component is just ignored.
Yeah sure you can add javascript in Angular.You can make one external Javascript file and put all your code inside that file.For example you file is external.js in /app folder.And now you can access that file functions in Angular component.This is the easiest way I found. You can use import to include your external file. Code for that will be following.
import './external.js';
declare var myExtObject: any;
Now use one variable here I named myExtObject to call External.js file function like following any where you want :
myExtObject.func1();