This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12452|Reply: 0

[Angular] Angular questions about getting Matrix URLs and normal URL query strings

[Copy link]
Posted on 6/4/2019 9:59:40 AM | | |
The Angular documentation does not provide a detailed explanation of how to obtain the querystring for these two URL specifications.

ActivatedRoute documentation:

interface ActivatedRoute {
  snapshot: ActivatedRouteSnapshot
  url: Observable<UrlSegment[]>
  params: Observable<Params>
  queryParams: Observable<Params>
  fragment: Observable<string>
  data: Observable<Data>
  outlet: string
  component: Type<any>|string|null
  get routeConfig(): Route|null
  get root(): ActivatedRoute
  get parent(): ActivatedRoute|null
  get firstChild(): ActivatedRoute|null
  get children(): ActivatedRoute[]
  get pathFromRoot(): ActivatedRoute[]
  get paramMap(): Observable<ParamMap>
  get queryParamMap(): Observable<ParamMap>
  toString(): string
}
The way to get these two URLs in different formats is the params above, queryParams

Both return an Observable observable object with a generic params

Go to the Params documentation below:

Here's a practice of taking out queryString

Matrix URL


Default URL


You can see that ActivatedRoute provides url, params, queryParams, etc. The ActivatedRoute attribute returns Observable, which can be used to monitor changes in urls and parameters.

Injection is used as follows:







Previous:JS stitches JSON-formatted objects into complex URL parameter methods
Next:Front-end Object.assign() usage
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com