W3cubDocs

/Angular

UrlSegment

class stable

Represents a single URL segment.

class UrlSegment {
  constructor(path: string, parameters: {...})
  path: string
  parameters: {...}
  get parameterMap
  toString(): string
}

Description

A UrlSegment is a part of a URL between the two slashes. It contains a path and the matrix parameters associated with the segment.

Example

@Component({templateUrl:'template.html'})
class MyComponent {
  constructor(router: Router) {
    const tree: UrlTree = router.parseUrl('/team;id=33');
    const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
    const s: UrlSegment[] = g.segments;
    s[0].path; // returns 'team'
    s[0].parameters; // returns {id: 33}
  }
}

Constructor

constructor(path: string, parameters: { [name: string]: string; })

Parameters

path

The path part of a URL segment

parameters

The matrix parameters associated with a segment

Properties

Property Type Description
path string

The path part of a URL segment

The path part of a URL segment

Declared in constructor.
parameters { [name: string]: string; }

The matrix parameters associated with a segment

The matrix parameters associated with a segment

Declared in constructor.
parameterMap Read-only.

Methods

toString()

toString(): string

Parameters

There are no parameters.

Returns

string

© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/router/UrlSegment