I have developed a class structure for managing Schedules. I then brought in this class to my primary program. My issue arises from the fact that this class utilizes the HttpClient, which I was instructed to set up within the constructor. As a result, when I attempt to create a new instance of the Schedule (i.e., newSchedule = new Schedule;), it prompts me for a parameter instead of the HttpClient. How can I avoid specifying the HttpClient when creating a new object of the class?
Below is an example of the Schedule model class:
import { HttpClient } from '@angular/common/http';
export class Schedule {
constructor(private httpClient: HttpClient) {}
}
However, now I am required to provide this.HttpClient within my main program, even though it is unnecessary:
import { HttpClient } from '@angular/common/http';
export class AppComponent {
constructor(private httpClient: HttpClient) {}
var NewSchedule = new Schedule(this.HttpClient);
}
How can I eliminate the necessity of passing this.HttpClient? It seems like there could be a flaw in my approach.