Angular 5, NullInjectorError: No Provider For Service
Answer :
You need to add TesteventService under providers under imports in your app.module.ts
providers: [ TesteventService ]
Annotate your service class with -
@Injectable({ providedIn: 'root' })
The service itself is a class that the CLI generated and that's decorated with @Injectable()
. By default, this decorator has a providedIn
property, which creates a provider for the service. In this case, providedIn: 'root'
specifies that Angular should provide the service in the root injector.
Comments
Post a Comment