Issue
I am quite new to Angular and perhaps missing some obvious solution. When application goes offline I cannot display component AlertComponent, because of obvious offline error (ChunkLoadError: Loading chunk 22 failed). If this component was already diplayed before going offline then everything works as expected - scripts are loaded for this component and even after going offline the alert is displayed. So the question is how to preload this component to be accessible after going offline?? Or some other solution is better?
As I understand the preloading strategy PreloadAllModules does not apply in this situation because it preloads components defined for routing.
I use ionic 5.5.2, angular 10
Solution
The best way to add offline capabilities to your website or web application is to turn it into a "progressive web app". Specifically you need to add a service worker to pre-fetch and cache required (static) resources.
Angular already has support for service workers. You can add a service worker to your app with the following command:
$ ng add @angular/pwa --project *project-name*
See the Angular documentation for details.
Answered By - rveerd
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.