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

530 Valid Hostname Is Expected When Setting Up IIS 10 For Multiple Sites

Android - ImageView With Rounded Only One Corner

Android - SetOnClickListener Vs OnClickListener Vs View.OnClickListener