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.…
Author
Released
11/1/2016- 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
Duration
Views
Related Courses
-
C# & .NET: Programming
with Alexander Zanfir1h 14m Intermediate
-
Introduction
-
Welcome48s
-
-
1. Course Overview
-
Sample application1m 18s
-
Environment setup2m 46s
-
2. Components
-
Components explained2m 13s
-
Component bootstrapping3m 29s
-
-
3. Directives, Interpolation, and Templates
-
Using interpolation2m 7s
-
Using ngIf and ngFor6m 35s
-
4. Binding
-
Binding overview1m 36s
-
Adding event binding code3m 28s
-
Implementing two-way binding2m 53s
-
Transforming data1m 58s
-
-
5. Advanced Components
-
Using an interface3m 7s
-
Wrapping styles1m 26s
-
Writing lifecycle hooks3m 34s
-
Creating nested components3m 40s
-
Using nested components2m 28s
-
-
6. Services
-
Services explained1m 24s
-
Creating a movie service3m 2s
-
Injecting a movie service2m 34s
-
-
7. Obtaining Data with HTTP
-
HTTP requests4m 14s
-
Observables4m 1s
-
8. Routing
-
Routes overview1m 5s
-
Configuring routes, part 16m 30s
-
-
Conclusion
-
Next steps25s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Injecting a movie service