Zain Shafi
Zain Shafi

Reputation: 1

How to use JavaScript inside Angular component's HTML file?

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?

Upvotes: 0

Views: 738

Answers (1)

Akirus
Akirus

Reputation: 574

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.

Upvotes: 1

Related Questions