linkUrlMatcher
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;
linkDescription
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 }];