25 Routing and navigation: part 2
This chapter
- Using wildcards to define routes that match multiple URLs
- Using redirections to map from one URL to another
- Performing navigation within a component
- Using CSS styles to reflect changes in routes
- Using child routes to define common route configurations
In the previous chapter, I introduced the Angular URL routing system and explained how it can be used to control the components that are displayed to the user. The routing system has a lot of features, which I continue to describe in this chapter and chapter 26. The emphasis in this chapter is on creating more complex routes, including routes that will match any URL, routes that redirect the browser to other URLs, routes that navigate within a component, and routes that select multiple components. Table 25.1 summarizes the chapter.
Table 25.1. Chapter summary
Problem
|
Solution
|
Listing
|
Matching multiple URLs with a single route
|
Use routing wildcards
|
1–8
|
Redirecting one URL to another
|
Use a redirection route
|
9
|
Navigating within a component
|
Use a relative URL
|
10-11
|
Styling an element when a specific route is active
|
Use the
routerLinkActive attribute
|
12–14
|
Using the routing system to display nested components
|
Define child routes and use the
router-outlet element
|
15–20
|