Join Justin Schwartzenberger for an in-depth discussion in this video The Inject decorator, part of Angular 2 Essential Training (2016).
- [Voiceover] 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.…In the main.ts file we set up a provider…for the lookup lists value type…in the bootstrap function…so it would be available to that entire application.…Let's go over what you need to do to use that…in a class constructor.…The media item form component can benefit…from using this new lookup lists value type,…using it to help render out…the drop down options in the form.…Let's switch over to the…media-item-form.component.ts file.…
We need to import the inject decorator…found in Angular2/core…so let's add that to the import list.…Similar to how you can use some decorators…to decorate class properties,…the inject decorator is used to decorate function parameters…so we will add a new constructor parameter…named "lookuplists" and in front of it…we add "@inject" in parenthesis.…The inject decorator supports passing in…a string literal that represents the value type.…
- What is Angular?
- Setting up an Angular template
- Creating a component
- Displaying data
- Working with events
- Using two-way data binding
- Creating a subcomponent
- Using the built-in HTTP module
- Using the built-in router module
Skill Level Intermediate
AngularJS and WordPress: Building a Single-Page Applicationwith Roy Sivan31m 52s Intermediate
Building a Mobile App with AngularJS 1 and Ionicwith Ray Villalobos3h 31m Intermediate
1. Architecture Overview
3. Directives and Pipes
5. Dependency Injection and Services
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.