haochi / angular2-web-worker

Web worker for Angular 2
https://www.npmjs.com/package/angular2-web-worker
51 stars 10 forks source link

Angular 6 : NullInjectorError: No provider for WebWorkerService! #15

Open yogeshpaisode opened 5 years ago

yogeshpaisode commented 5 years ago

Hi, I am getting the following error when using with Angular 6.

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[AppComponent -> WebWorkerService]: StaticInjectorError(Platform: core)[AppComponent -> WebWorkerService]: NullInjectorError: No provider for WebWorkerService! Error: StaticInjectorError(AppModule)[AppComponent -> WebWorkerService]: StaticInjectorError(Platform: core)[AppComponent -> WebWorkerService]: NullInjectorError: No provider for WebWorkerService! at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:1062) at resolveToken (core.js:1300) at tryResolveToken (core.js:1244) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1141) at resolveToken (core.js:1300) at tryResolveToken (core.js:1244) at StaticInjector.push../nodemodules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1141) at resolveNgModuleDep (core.js:8369) at NgModuleRef.push../nodemodules/@angular/core/fesm5/core.js.NgModuleRef.get (core.js:9057) at resolveNgModuleDep (core.js:8369) at resolvePromise (zone.js:814) at resolvePromise (zone.js:771) at zone.js:873 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:3811) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188) at drainMicroTaskQueue (zone.js:595)

oriolmartin commented 5 years ago

use this:

import {WebWorkerService} from 'angular2-web-worker/web-worker.service';

kevanslumin commented 2 years ago
@Component({
    selector: 'something',
    templateUrl: './something.component.html',
    providers: [WebWorkerService],
})