Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the Angular services in a Worker?

I have a web worker created in which I want to use the current functions that are placed in an Angular Service. Tried passing them through the postMessage but that doesn't work.

like image 604
Sheki Avatar asked Oct 15 '25 04:10

Sheki


1 Answers

Short answer is that what you're asking can't be done. You cannot inject an Angular service into a worker. For background data, PWA actions, caching, calculations, and all that is doable, but not service injection. Think of a worker as a script built into the browser that wraps around your DOM, and Angular as a wrapper for javascript code that runs in the DOM. It's just not in Angular's scope to do that. At least, that's my take on the matter.

like image 158
Joosep Parts Avatar answered Oct 18 '25 08:10

Joosep Parts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!