I've been looking for solutions, but I can't seem to find one.
In my index.html
file, I've placed some script within the head
tag (even above the </body>
tag) and included a $(document).ready
function.
The issue I'm facing is that the script only works when the server starts. If I navigate away from the component where the script is used and return, the script ceases to work until I refresh the page.
My question is, how can I refresh just the index.html
without refreshing the entire application? Is there a way to reuse my script code repeatedly without encountering this issue?
I attempted to import an external js
file in the index.html
, but the function was not invoked. Likewise, trying to write JS
code within the AfterViewInit
lifecycle hook also proved unsuccessful.