UrlMatcher

type-alias

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

A function matching URLs

type UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => UrlMatchResult;

Description

A custom URL matcher can be provided when a combination of path and pathMatch isn't expressive enough.

For instance, the following matcher matches html files.

export function htmlFiles(url: UrlSegment[]) {
  return url.length === 1 && url[0].path.endsWith('.html') ? ({consumed: url}) : null;
}

export const routes = [{ matcher: htmlFiles, component: AnyComponent }];

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