角度paramMap与queryParamMap? [英] Angular paramMap vs queryParamMap?

查看:228
本文介绍了角度paramMap与queryParamMap?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

paramMap和queryParamMap有什么不同?

What are the different paramMap and queryParamMap?

Angular网站说
paramMap-一个Observable,其中包含特定于必需参数和可选参数的映射路线。该映射支持从同一参数检索单个和多个值。

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-一个Observable,其中包含可用于所有路由的查询参数的映射。该映射支持从查询参数中检索单个和多个值。

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.

谢谢

推荐答案

ParamMap适用于 user /:id Id 参数仅属于此路由。

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

QueryParamMap例如。 user /:id?tab = edit Tab 是全局查询参数,可以从用户路由组件及其任何祖先的ActivatedRoute中读取。

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.

这篇关于角度paramMap与queryParamMap?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆