Angular 7: NullInjectorError: No provider for PagerService
Following the error text, you have to import and add your PagerService
in the Provider part of your app.module.ts
file:
providers: [ PagerService, ],
And don't forget to declare it as Injectable
:
@Injectable()export class PagerService { // ...}
Your error is related to PagerService
, not with the underscore
NullInjectorError: No provider for PagerService! at
make sure your service is registered in list of providers at app.module or has the Injectable
declaration at top:
@Injectable({ providedIn: 'root',})
a common example of service in angular 7 is below:
import { Injectable } from '@angular/core';@Injectable({ providedIn: 'root',})export class MyService{ constructor() { }}
please refer to documentation for Services for more details.
Page Service or Job Service both should have Injectable attribute applied or check if you are injecting something in these services also then same applies to that also.