Going through this todo tutorial and it has the following:
import {TodoDataService} from './todo-data.service';
@Component({
// ...
providers: [TodoDataService]
})
constructor(private todoDataService: TodoDataService) {
}
IIUC we have to declare the TodoDataService
in the providers array. This seems redundant. Could the Angular DI read the generated metadata for the component and automatically inject the TodoDataService
using constructor injection?
Update
Angular has implemented this to some extent now. I asked them to remove providedIn:root
as well and they said they have things on the roadmap for that.