5 lines
4.5 KiB
JSON

{
"id": "api/router/UrlMatcher",
"title": "UrlMatcher",
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/router\", \"name\": \"@angular/router\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/router/UrlMatcher\", \"name\": \"UrlMatcher\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/router\">@angular/router</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/router/src/config.ts?message=docs(router)%3A%20describe%20your%20change...#L41-L65\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/router/src/config.ts#L41-L65\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"urlmatcher\">UrlMatcher<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/UrlMatcher#urlmatcher\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label type-alias\">type-alias</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>A function for matching a route against URLs. Implement a custom URL matcher\nfor <code><a href=\"api/router/Route#matcher\" class=\"code-anchor\">Route.matcher</a></code> when a combination of <code>path</code> and <code>pathMatch</code>\nis not expressive enough. Cannot be used together with <code>path</code> and <code>pathMatch</code>.</p>\n\n <p><a href=\"api/router/UrlMatcher#description\">See more...</a></p>\n </section>\n \n \n \n <section class=\"type-alias-overview\">\n <code-example language=\"ts\" hidecopy=\"true\">\n type <a href=\"api/router/UrlMatcher\" class=\"code-anchor\">UrlMatcher</a> = (segments: <a href=\"api/router/UrlSegment\" class=\"code-anchor\">UrlSegment</a>[], group: <a href=\"api/router/UrlSegmentGroup\" class=\"code-anchor\">UrlSegmentGroup</a>, route: <a href=\"api/router/Route\" class=\"code-anchor\">Route</a>) => <a href=\"api/router/UrlMatchResult\" class=\"code-anchor\">UrlMatchResult</a> | null;\n </code-example>\n </section>\n\n \n\n \n \n<section class=\"description\">\n <h2 id=\"description\">Description<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/UrlMatcher#description\"><i class=\"material-icons\">link</i></a></h2>\n <p>The function takes the following arguments and returns a <code><a href=\"api/router/UrlMatchResult\" class=\"code-anchor\">UrlMatchResult</a></code> object.</p>\n<ul>\n<li><em>segments</em> : An array of URL segments.</li>\n<li><em>group</em> : A segment group.</li>\n<li><em>route</em> : The route to match against.</li>\n</ul>\n<p>The following example implementation matches HTML files.</p>\n<code-example>\nexport function htmlFiles(url: <a href=\"api/router/UrlSegment\" class=\"code-anchor\">UrlSegment</a>[]) {\n return url.length === 1 &#x26;&#x26; url[0].path.endsWith('.html') ? ({consumed: url}) : null;\n}\n\nexport const routes = [{ matcher: htmlFiles, component: AnyComponent }];\n</code-example>\n\n \n</section>\n\n\n \n\n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/router\n - api/router/Route\n - api/router/UrlMatchResult\n-->\n<!-- links from this doc:\n - /api\n - api/router\n - api/router/Route\n - api/router/Route#matcher\n - api/router/UrlMatchResult\n - api/router/UrlMatcher#description\n - api/router/UrlMatcher#urlmatcher\n - api/router/UrlSegment\n - api/router/UrlSegmentGroup\n - https://github.com/angular/angular/edit/master/packages/router/src/config.ts?message=docs(router)%3A%20describe%20your%20change...#L41-L65\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/router/src/config.ts#L41-L65\n-->"
}