Find out how to add optional route parameters to the URL of your Angular 2 application to save data based on input from your users.
- [Instructor] Optional route parameters…are appended to the URL after the required path information.…While there are no strict rules for using…optional route parameters, the Angular team…does recommend limiting their use to discretionary…data that does not distinguish one route path…from another, or that is too complex…for Angular's standard routing.…Filtering a user list like ours…is an excellent candidate for optional route parameters.…Let's replace the use of local storage…and our user list component with…an optional route parameter.…
We start by importing the router class…from the angular router module, instantiating…an instance of that class in our constructor.…At the top of our file, we'll create…a new import statement.…Importing the router class between the brackets…from @angular/router.…Take note that the router class…has a capital R, while the router module…has a lowercase R.…In our constructor, we'll create a new private variable…called Router, and assign it to the class of Router.…
Again, watching for capitals.…
- 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.