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

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable