Reynald demos how to use our service to get movies in the movie list component. We'll define our movie as a dependency in the movie list component. When an instance of the movie list component is created, the Angular injector creates an instance (via dependency injection) of the movie service. Now we can actually use the service.
- [Instructor] It's now time to inject our service.…We want to use our service to get movies,…in the movie list component.…So, we'll define our movie as a dependency…in the movie list component.…The first thing we want to do, is to go to…our movie-list.component.ts file.…Let's open that up, and import the movie service.…And, we're going to add a constructor.…So, let's first add our import statement,…for our movie service.…And, we're going to add a constructor,…right above our toggle image method.…
So, with this constructor,…now, when an instance of the movie list component…is created, the Angular injector creates…an instance of the movie service.…Now, we can actually use a service.…Let's remove the hard-coated data records…from this file here,…that we had earlier.…And, what we're going to do, is just basically indicate,…Imovie array for…the movies property.…Just like this.…
All right.…We got rid of Titanic,…and I believe the other movie was Sully.…Right?…Let's see here, let's back up.…And Jaws.…Titanic and Jaws.…So, let's remember that.…
- Creating components
- Bootstrapping components
- Working with templates
- Using directives and interpolation
- Binding and transforming data
- Creating advanced and nested components
- Creating services
- Obtaining data with HTTP calls
- Configuring routes
Skill Level Intermediate
1. Course Overview
3. Directives, Interpolation, and Templates
5. Advanced Components
7. Obtaining Data with HTTP
- 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.