Find out how to write custom services for your Angular 2 application to make getting data from web storage much easier as your application grows.
- [Instructor] Let's add a custom service so we can get…data from browser storage.…A custom service like this makes working…with browser storage easier as our application grows…because the service can be used across multiple components…with all changes taking place at the service level…instead of each individual component.…We'll start by creating a new file…in the shared folder in our application.…You can call this new file whatever you'd like.…I'll call mine browser storage,…and we'll follow Angular's file naming conventions,…browser-storage.service.ts.…
All Angular services must be declared as injectable…using the injectable decorator imported…from the Angular core module.…We do that by creating a new import statement in our file…and between the brackets importing Injectable…from @angular/core.…We declare a file as injectable by creating a new line…and typing @injectable().…
We'll then export a class.…Following the naming convention we use throughout the…application, a custom namespace of Xyz, followed by the name…
- Overview of data storage options
- Saving and retrieving data from the browser
- Setting routes in the URL
- Using query strings and fragments instead of routes
- Saving and retrieving data from a server
- Working with user input
- Using JSONP instead of HTTP
- Why writing custom services is important
- Writing custom services for working with browsers and servers
Skill Level Intermediate
1. Getting Started
Application overview1m 39s
2. Data Storage Options
3. Storing Data in the Browser
4. Storing Data on a Server
5. Writing Custom Services
- 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.