Angular6 Service Worker and background sync

☆樱花仙子☆ 提交于 2019-11-30 21:06:52

Yes you can use your custom script to extend the capabilities of Angular's service worker.

Just follow below steps:

  1. Create a js file with your custom script let's say sw-custom.js under src directory of your project.
  2. Add "importScripts('./ngsw-worker.js')" at top of sw-custom.js file.
  3. Add sw-custom.js file to angular.json file under scripts section.
  4. Now register your sw-custom.js file in app module instead of

ngsw-worker.js

That's it now you can write your script here as per your need.

Maybe it is not correct approach but it works.

Here is the blog for same.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!