Amr Ibrahim
Amr Ibrahim

Reputation: 2234

How to include script tag while Angular2 running ?

How to include this external java script library inside Angular2 page view .

I want to include this

 <!-- google maps javascript -->
 <script src="//maps.googleapis.com/maps/api/js?key=#######&sensor=true"></script>

so when this page is in view this library is loaded and start working .

Upvotes: 3

Views: 2429

Answers (1)

Maxime G&#233;linas
Maxime G&#233;linas

Reputation: 2330

You can't.
The Angular processor remove all script tag in the template files for a security reason.


Alternatives:

  • Put your script in the index.html
  • Import it directly in your component .ts file using import 'path/to/file'.

Upvotes: 2

Related Questions