I have been working on creating a service to make http requests and hence I'm using HttpClientModule given by Angular. I have data.serivce.ts file where the service is declared and I'm importing the HttpClient as shown below.
import { Injectable } from '@angular/core';
import { HttpClient} from '@angular/common/http'
@Injectable()
export class DataService {
constructor(private http:HttpClient) {
}
validateLogin(){
return this.http.get('https://someurl')
}
}
Since I'm injecting the dependency of DataService in the providers array of the app.module.ts, I don't understand why I need to import the HttpClientModule again in the app.module.ts
HttpClientModuleinto the mainmodule, you can inject the HttpClient` into an application class like your service