Tost84226
Tost84226

Reputation: 1

How can I include js file in Angularjs2 component

I try to include *.js in [ *.component.html ] file

like this :

<script src="modal.js" type="text/javascript"></script>

but it doesn't load.

Only success I got , when I try to load *.js is in src/index.html.

I am a newbie at Angular2 ,I don't know how to load js flie in Angular 2 project .

any inputs?

Upvotes: 0

Views: 271

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657098

<script> tags in templates are not added to the DOM, they are just stripped from the template. You need to use other means to add the script. For example require()

Upvotes: 1

Related Questions