Scripts not being loaded when changing routes
I have an Angular CLI application that consists of multiple components. The issue is that when navigating from component A to component B, component B will loose bindings to the external scripts. I added the external scripts using the recommended way of using app[0].scripts.
What I've observed is that scripts are only loaded when I refresh the page.
I would like guidance as to what I'm doing wrong. Details of my solution and environment setup are provided below.
Version details: Angular CLI: 1.7.0 Node: 8.9.4 OS: win32 x64 Angular: 5.2.5
Repo https://github.com/ntombela/angular-demo
Add scripts globally as:
Try to add the script file as globally on the file
.angular-cli.json
Add the path of the script files like this in the file
"scripts": [
"script.js"
]
Remove the other imports.
I'm not following. What file is script.js?
the external script
Got it right. Thanks. I had to subscribe to the router events to know when navigation has ended and then load the scripts.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.