I am not sure which Angular version your are trying to run with web worker so I am providing all the details that I have for running Angular with Web worker.
In order to use Web Workers in your Angular App you have two choices:
- Run all the business logic of your App in different Web Worker thread.
- Run Some of CPU intensive logic of your App in Web worker thread. The rest of the application will keep running in Main thread.
Choice #1 with Angular 6 generated using Angular CLI 6:
Article: Using web workers with Angular 6
Choice #1 with Angular 5 or below generated using Angular CLI 1:
Blog: Angular with Web Worker: Step by Step
Choice #2 With Angular 5 or Angular 6
SlideShare: Web Worker in your Angular Application
All these references do have a sample code reference available in Github.
I hope this will be helpful for you to understand different use cases and choose the best one that fits your application need.