填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

UrlSegment

Represents a single URL segment.

查看"说明"...

      
      class UrlSegment {
  constructor(path: string, parameters: { [name: string]: string; })
  path: string
  parameters: {...}
  parameterMap
  toString(): string
}
    

说明

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(path: string, parameters: { [name: string]: string; })
      
      constructor(path: string, parameters: { [name: string]: string; })
    
参数
path string

The path part of a URL segment

parameters object

The matrix parameters associated with a segment

属性

属性说明
path: string Declared in constructor.

The path part of a URL segment

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

The matrix parameters associated with a segment

parameterMap 只读

方法

toString(): string
      
      toString(): string
    
参数

没有参数。

返回值

string

使用说明

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