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.

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

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

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