The inject() Function
Explain how the inject() function provides an alternative to constructor injection and where it's required rather than optional.
The inject() function lets you retrieve a dependency from Angular's DI system without declaring it as a constructor parameter — it's called directly inside a field initializer, a factory function, a functional guard, or anywhere else that executes within what Angular calls an "injection context." It was introduced primarily to support functional APIs (guards, resolvers, interceptors) that are plain functions with no constructor to attach parameters to, but it's since become popular as a general alternative to constructor injection even inside classes.
Constructor injection is like having ingredients delivered to your kitchen counter before you start cooking; inject() is like reaching into the pantry yourself mid-recipe — both get you the ingredient, but reaching into the pantry only works while you're still standing in the kitchen (the injection context), not after you've already left for the day.