This is the archived documentation for Angular v5. Please visit angular.io to see documentation for the current version of Angular.

UrlSegment

npm Package @angular/router
Module import { UrlSegment } from '@angular/router';
Source router/src/url_tree.ts

Represents a single URL segment.

Overview

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

How To Use

      
      @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}
  }
}
    

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.

Constructor

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

Members

      
      path: string
    

The path part of a URL segment


      
      parameters: {
    [name: string]: string;
}
    

The matrix parameters associated with a segment


      
      get parameterMap
    

      
      toString(): string