Take a brief look at an example application used in this course to demonstrate all the data management options available for your Angular 2 application.
- [Narrator] The ability for users to save state in between page reloads and browser sessions is a common and highly sought after piece of functionality for any application. Throughout this course, we'll be using this application as our sample. It's a simple app that displays a list of available users that are online right now. I've opened the source code here, in Visual Studio code. The list of users is displayed using our user list component and user list template. When the component is initialized on page load, it requests the user list from our custom user list service, inside the ngoninit method, and attaches the response to our user variable in the component.
In our user list template, we iterate over each user using the ngfor directive, displaying each result as it's own un-ordered list item. When our app loads in the browser, viewers have the ability to filter the list of users by name and the UI updates accordingly, thanks to the onfilter method in the component. Right now, if a user reloads the page, the filters are lost. Our app does not store data about any filters that might be present on the page. Our job in this course will be to add functionality that allows users to save the current filter state in between sessions.
Our user list service is currently receiving information about the user list from a static file called mock users located in the mock folder in our app directory. We're using a static file for right now to keep the code focused on how data is stored and retrieved from the browser.
- 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