Join Justin Schwartzenberger for an in-depth discussion in this video The opaque token, part of Angular 2 Essential Training (2016).
- View Offline
- Exercise Files
- Code Practice
- [Voiceover] So the inject decorator…with its string literal works…but there's a better way to do this.…Relying on string literals for tokens…is always a bit of a risk.…They are harder to maintain,…easier to mistype and code editors don't have much…opportunity to keep track of them to aid in refactoring.…Angular has a solution for this,…it's called an opaque token.…You can use an opaque token to tell Angular…you wanna have a concrete type…that can be passed around.…Let's refactor the lookup lists value type…to use an opaque token.…
First let's create a new file…called providers.ts…and let's move the lookup lists value instantiation…from the main.ts file…into this new file.…Now the provide function over in the bootstrap call…is going to need this lookup lists variable…so let's add the export keyword…in front of the var statement…so that we can import it over in main ts.…Alright, to create an opaque token…we need to import the class type.…
It's in the angular2/core module bundle,…so let's add the import statement for that.…
- 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.