Angular paramMap vs queryParamMap?

a 夏天 提交于 2019-12-12 10:46:30

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/49615857/angular-parammap-vs-queryparammap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!