I am currently working on an Angular2 component that has a template which relies on JavaScript calls to load various components such as Facebook, Google Maps, and custom scripts.
The necessary scripts are already loaded in the index.html file, so all I need to do is call them to update their contents.
My question is: How can I call my JavaScript methods in Angular2 each time the view is changed?
For example, consider the following code snippet from myJavaScript.js:
loadData(){
...
}
$(document).load(loadData());
My goal is to trigger the loadData() function every time the router revisits my component. How can this be achieved in Angular2?