Find out how to add functionality in your Angular 2 application to get data from web storage on page load and when your users refresh the page.
- [Narrator] We get items in session storage using…the Get Item method of the session storage property…found on the browser's window object.…Session storage is a built in browser global…and no special angular code is needed…to use this feature.…In our application let's add functionality…in our user list component that retrieves the…filter from session storage on page load…if a filter is available.…This is done by adding a reference to…the session storage property inside our n-g init…method in the component.…
N-g init is a special angular method…that fires once for each instance of a component.…In our case this means n-g init will fire…once on page load which is a perfect time…to retrieve filter data from session storage.…We do this by creating a new line in our method…and assigning the the this dot filter property…to the value of window dot session storage…dot get item.…The get item method takes one argument.…A string or variable name representing the key…of the data we want to access.…
For us this variable name is this dot storage key.…
- 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.