The route path and parameters are available through an injected router service called the ActivatedRoute. It has a great deal of useful information including.
Property | Description |
url | An Observable of the route path(s), represented as an array of strings for each part of the route path. |
data | An Observable that contains the data object provided for the route. Also contains any resolved values from the resolve guard. |
paramMap | An Observable that contains a map of the required and optional parameters specific to the route. The map supports retrieving single and multiple values from the same parameter. |
queryParamMap | An Observable that contains a map of the query parameters available to all routes. The map supports retrieving single and multiple values from the query parameter. |
fragment | An Observable of the URL fragment available to all routes. |
outlet | The name of the RouterOutlet used to render the route. For an unnamed outlet, the outlet name is primary. |
routeConfig | The route configuration used for the route that contains the origin path. |
parent | The route’s parent ActivatedRoute when this route is a child route. |
firstChild | Contains the first ActivatedRoute in the list of this route’s child routes. |
children | Contains all the child routes activated under the current route. |
Two older properties are still available. They are less capable than their replacements, discouraged, and may be deprecated in a future Angular version.
- params — An Observable that contains the required and optional parameters specific to the route. Use paramMap instead.
- queryParams — An Observable that contains the query parameters available to all routes. Use queryParamMap instead.