Trying to use this article (among others) to get my first Angular program to run. I am trying to get my service to use HttpClient, but neither passing in the interface to my new service, an instance of HttpClient to the service's constructor, nor an instance of HttpClientModule to the service's constructor seems to work
// from app.component.ts
export class AppComponent {
client = new HttpClientModule();
service = new CharactersheetService(this.client);
//Argument of type 'HttpClientModule' is not assignable to parameter of type 'HttpClient'.
//contructor(private myService : ICharacterSheetService) {}; // Also generates errors
...
// from charactersheet.service.ts
@Injectable({
providedIn: 'root'
})
export class CharactersheetService implements ICharacterSheetService {
constructor(private httpClient : HttpClient){}; // declaring as HttpClientModule adds more errors
public getSheetById() { ...
I thought that importing HttpClientModule and HttpClient let you inject an instance of HttpClient in the service. What am I doing wrong?