In this video, learn how to use the @Inject decorator to get a custom provider value into a component.
- [Instructor] Constructor injection of class types … can be done with a bit of TypeScript and that's it. … To get value types injected into constructors, … Angular needs a bit more help. … Let's create a value provider for our app … to store some lookup lists and provide them at bootstrap. … In the app dot module dot ts file, … we can add a local variable named lookupLists … and set it to an object literal with a property for mediums. … To add the value to the providers, … we need to add it to the list … of providers in the module metadata. … But to do that for a value provider, … we need to use a different syntax … to add it to the providers array. … We can add a provider object literal as an array entry here. … The provider object literal needs a property named provide … that gets set to either a type or a string literal. … For our lookupLists we can set it … to a string literal of lookupListToken. … And then it needs the value to use. … We can make use of another property named useValue …
- What is Angular?
- Working with components
- Binding events and properties
- Getting data to components
- Using directives and pipes
- Creating Angular forms
- Validating form data
- How Angular does dependency injection
- Making HTTP calls
- Styling components
Skill Level Intermediate
Angular: Building an Interfacewith Ray Villalobos2h 20m Intermediate
1. Architecture Overview
3. Directives and Pipes
5. Dependency Injection and Services
8. Styling Components
Next steps1m 20s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.