I know that it is not ideal to reload an Angular Single Page Application. However there is a place that I need to reload the full application.
TSLint says that reload is deprecated.
Is there any alternative for this?
Using location. reload() is the valid syntax. It is only the reload with forcedReload which is deprecated. In your case changing location.
True reloads the page from the server (e.g. does not store the data cached by the browser): window. location. reload(true); False reloads the page using the version of the page cached by the browser.
Window location. The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.
You can use the following code: window. stop();
You can use location.reload()
without the forceReload flag. This is just deprecated because it is not in the spec: https://www.w3.org/TR/html50/browsers.html#dom-location-reload
If you look at interface definition for Location you will see the following:
/** * Reloads the current page. */ reload(): void; /** @deprecated */ reload(forcedReload: boolean): void;
Using location.reload()
is the valid syntax. It is only the reload with forcedReload which is deprecated.
In your case changing location.reload(true)
to location.reload()
to resolve your issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With