In my Angular component, inside the HTML file, the script tags aren't working. Only HTML is being rendered but not JavaScript. Can someone help me out?
Asked
Active
Viewed 455 times
0
-
2Hello, could you expand on what you need so we can help you better? Do you need to add javascript code in your component's template? If so why? Maybe there is another way to do what you need that does not require to do so. If you want to load a third party script the answers here might help you. https://stackoverflow.com/questions/34140065/script-tag-in-angular2-template-hook-when-template-dom-is-loaded – Ruina Oct 14 '21 at 12:00
-
I actually want to implement an Angular program that can graphically display data of csv files using bar graphs. – Zain Shafi Oct 27 '21 at 09:54
1 Answers
1
To add js script tags in an Angular project you need to have the script tag created and added to the DOM programatically.
A potential solution is having a "ScriptMakerService" that you inject into your app.component or the top component of the module that requires the script. This way when the module is loaded the script is created, added to the DOM and then loaded.

Akirus
- 554
- 4
- 9