In this example, we’ll learn how to use component’s and service’s constructors with Angular 10 and previous versions.

We’ll see how to provide dependencies as constructor parameters to components or services and use the @Optional and @Inject decorators for adding optional dependencies or create injection tokens to pass parameters to services.

As a prerequisite, you need to have Angular CLI v10 installed on your development machine.

You can also use the online Stackblitz IDE if you don’t have a development environment ready yet.

#angular

Angular 10 Constructor Parameters with Inject and Optional Decorators
9.70 GEEK