Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular paramMap vs queryParamMap?

What are the different paramMap and queryParamMap?

Angular website says 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.

I would like to know when I have to use with examples.

Thanks

like image 878
Su Park Avatar asked Apr 02 '18 17:04

Su Park


People also ask

What is the use of ParamMap in Angular?

ParamMaplinkA map that provides access to the required and optional parameters specific to a route. The map supports retrieving a single value with get() or multiple values with getAll() .

What is RouterState in Angular?

Angular RouterState is the state of the router as a tree of activated routes. It tells how the various components of an application are arranged on the screen to define what should be displayed on it. RouterState represents the state of the router as it keeps changing over time when users navigate from page to page.

What is ParamAP?

Here we introduce ParamAP, a standalone cross-platform computational tool that uses a template-free detection algorithm to automatically identify and parameterize APs from text input files.

What is Routermodule in Angular?

Adds directives and providers for in-app navigation among views defined in an application. Use the Angular Router service to declaratively specify application states and manage state transitions.


2 Answers

ParamMap for routes like user/:id. Id param belongs only this route.

QueryParamMap is for eg. user/:id?tab=edit. Tab is a global query param, it can be read from the ActivatedRoute in the user route's component as well as any of its ancestors.

like image 76
funkizer Avatar answered Oct 25 '22 12:10

funkizer


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.

like image 29
DV Singh Avatar answered Oct 25 '22 11:10

DV Singh