Find out how to use localStorage in your Angular 2 application to save data in the browser even after your users close their web browser.
- [Narrator] Items in session storage exist…as long as the current browser window or tab…remains open.…Data in session storage is erased and forgotten…as soon as the window or tab is closed.…To store data between browser sessions,…we need to use local storage…in place of session storage.…Local storage is a built in browser global,…just like session storage,…and no special Angular code is needed…to use this feature.…The API for local storage and session storage…are identical, so all we need to do…is change all occurrences of session storage in our code…to use local storage instead.…
Visual Studio code makes that very easy to do.…We right click on the property we want to change,…select change all occurrences,…and type the new value.…You'll see that our references in the ngoninit method,…on filter method and on clear method…have all updated correctly.…All code editors are unique,…and I encourage you to explore your code editor…to find similar functionality.…If we go back to the browser…and look at the application tab…
- 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.