From the course: Angular Essential Training

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Declaring dependencies using dependency injection

Declaring dependencies using dependency injection - Angular Tutorial

From the course: Angular Essential Training

Declaring dependencies using dependency injection

- [Instructor] Earlier in this course, we looked at how to inject dependencies into your application using Angular's dependency injection. In this video, we'll look at how to declare those dependencies to make them available for use. I opened our project here in a GitHub Codespace. I talked about why we use Codespaces earlier in this course, so for now, just think of them as an easy way to share and write code without installing anything on your local machine. I'll go to the src folder. Open up the app folder, services and click on api.service.ts to open the file. This is the code for our custom API Service. Dependency injection and Angular services are closely linked. You can't use one without the other and most of the time services are all you need but you can inject other things too like strings, booleans, and object literals, as long as you give Angular a provider for that dependency. We'll look at providers in…

Contents