Currently following a step-by-step guide on managing tasks and it includes the following code snippet:
import {TodoDataService} from './todo-data.service';
@Component({
// ...
providers: [TodoDataService]
})
constructor(private todoDataService: TodoDataService) {
}
It appears that we need to declare the TodoDataService
in the providers array. This feels repetitive. Is there a way for Angular's Dependency Injection to automatically recognize the component's metadata and inject the TodoDataService
through the constructor?
Update
Angular seems to have made some progress in this area according to certain sources. I even suggested that they eliminate providedIn:root
and they mentioned having plans for that in their future updates.