UrlMatcher

type-alias

A function matching URLs

See more...

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–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v6.angular.io/api/router/UrlMatcher