0

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?

1 Answer 1

1

<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()

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks your answer,I try to write typescript code in my project,don't use native js file.
Not sure what your comment means. Do you need a different answer?
No,I think use Typescript in Angularjs 2 project is best way,Reduce use Javascript

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.