Reynald demos the beginning of creating a service and shows how steps are similar to building our components. He creates a file for the movie service. He then creates the class and adds an Injectable decorator. Next is adding a getMovies service to return a list of movies. With this service, we're removing the component’s responsibility to manage the date and letting the role go to the service. This makes it more reusable.
- [Instructor] So we have some hard-coded data that actually…represents the records for each movie.…It's best to have that separated into a service…that provides that data.…So let's go ahead and begin working on…creating that service.…What we'll do is create a service class called…movie.service.ts,…and we will place that under our movies folder,…movie.service.ts, click OK.…
And the next thing we'll want to do is to create…our class and add an Injectable decorator.…And that's simply done by adding the decorator…with the at sign and the keyword Injectable,…and then our class right below it.…So in order to get the compiler not to complain,…of course, we need to add…our import statement for Injectable,…and that should go away.…This decorator is optional.…If the service has its own dependency injection,…then decorator won't be needed, but we are going to have it…in this case.…
The next thing we'll want to do is to add our properties…inside of the class.…And the properties that we're going to care for…is to have getMovies method and have it handle…
- 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.