5 lines
60 KiB
JSON
5 lines
60 KiB
JSON
{
|
|
"id": "api/common/Location",
|
|
"title": "Location",
|
|
"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/common\", \"name\": \"@angular/common\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/common/Location\", \"name\": \"Location\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/common\">@angular/common</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L22-L256\" 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/common/src/location/location.ts#L22-L256\" 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=\"location\">Location<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#location\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label class\">class</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 service that applications can use to interact with a browser's URL.</p>\n\n <p><a href=\"api/common/Location#description\">See more...</a></p>\n </section>\n \n \n \n <section class=\"class-overview\">\n<code-example language=\"ts\" hidecopy=\"true\">\nclass <a href=\"api/common/Location\" class=\"code-anchor\">Location</a> {\n <a class=\"code-anchor\" href=\"api/common/Location#normalizeQueryParams\">static <span class=\"member-name\">normalizeQueryParams</span>: (params: string) => string</a>\n <a class=\"code-anchor\" href=\"api/common/Location#joinWithSlash\">static <span class=\"member-name\">joinWithSlash</span>: (start: string, end: string) => string</a>\n <a class=\"code-anchor\" href=\"api/common/Location#stripTrailingSlash\">static <span class=\"member-name\">stripTrailingSlash</span>: (url: string) => string</a>\n <a class=\"code-anchor\" href=\"api/common/Location#path\"><span class=\"member-name\">path</span>(includeHash: boolean = false): string</a>\n <a class=\"code-anchor\" href=\"api/common/Location#getState\"><span class=\"member-name\">getState</span>(): unknown</a>\n <a class=\"code-anchor\" href=\"api/common/Location#isCurrentPathEqualTo\"><span class=\"member-name\">isCurrentPathEqualTo</span>(path: string, query: string = ''): boolean</a>\n <a class=\"code-anchor\" href=\"api/common/Location#normalize\"><span class=\"member-name\">normalize</span>(url: string): string</a>\n <a class=\"code-anchor\" href=\"api/common/Location#prepareExternalUrl\"><span class=\"member-name\">prepareExternalUrl</span>(url: string): string</a>\n <a class=\"code-anchor\" href=\"api/common/Location#go\"><span class=\"member-name\">go</span>(path: string, query: string = '', state: any = null): void</a>\n <a class=\"code-anchor\" href=\"api/common/Location#replaceState\"><span class=\"member-name\">replaceState</span>(path: string, query: string = '', state: any = null): void</a>\n <a class=\"code-anchor\" href=\"api/common/Location#forward\"><span class=\"member-name\">forward</span>(): void</a>\n <a class=\"code-anchor\" href=\"api/common/Location#back\"><span class=\"member-name\">back</span>(): void</a>\n <a class=\"code-anchor\" href=\"api/common/Location#onUrlChange\"><span class=\"member-name\">onUrlChange</span>(fn: (url: string, state: unknown) => void)</a>\n <a class=\"code-anchor\" href=\"api/common/Location#subscribe\"><span class=\"member-name\">subscribe</span>(onNext: (value: PopStateEvent) => void, onThrow?: (exception: any) => void, onReturn?: () => void): SubscriptionLike</a>\n}\n</code-example>\n\n \n \n <div class=\"descendants class\">\n <h2 id=\"subclasses\">Subclasses<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#subclasses\"><i class=\"material-icons\">link</i></a></h2>\n \n\n<ul>\n \n <li>\n <code><a href=\"api/common/testing/SpyLocation\" class=\"code-anchor\">SpyLocation</a></code>\n \n\n\n </li>\n \n</ul>\n\n\n </div>\n \n\n</section>\n\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/common/Location#description\"><i class=\"material-icons\">link</i></a></h2>\n <p>Depending on the <code><a href=\"api/common/LocationStrategy\" class=\"code-anchor\">LocationStrategy</a></code> used, <code><a href=\"api/common/Location\" class=\"code-anchor\">Location</a></code> persists\nto the URL's path or the URL's hash segment.</p>\n\n <p>Further information available in the <a href=\"api/common/Location#usage-notes\">Usage Notes</a>...</p>\n</section>\n\n \n<section class=\"static-properties\">\n <h2 id=\"static-properties\">Static properties<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#static-properties\"><i class=\"material-icons\">link</i></a></h2>\n <table class=\"is-full-width list-table property-table\">\n <thead>\n <tr>\n <th>Property</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n \n <tr class=\"static-property\">\n <td>\n <a id=\"normalizeQueryParams\"></a>\n <code class=\"\"><a href=\"api/upgrade/static\" class=\"code-anchor\">static</a> <span class=\"member-name\">normalizeQueryParams</span>: (params: string) => string</code>\n </td>\n <td>\n \n <p>Normalizes URL parameters by prepending with <code>?</code> if needed.</p>\n\n \n </td>\n </tr>\n \n <tr class=\"static-property\">\n <td>\n <a id=\"joinWithSlash\"></a>\n <code class=\"\"><a href=\"api/upgrade/static\" class=\"code-anchor\">static</a> <span class=\"member-name\">joinWithSlash</span>: (start: string, end: string) => string</code>\n </td>\n <td>\n \n <p>Joins two parts of a URL with a slash if needed.</p>\n\n \n </td>\n </tr>\n \n <tr class=\"static-property\">\n <td>\n <a id=\"stripTrailingSlash\"></a>\n <code class=\"\"><a href=\"api/upgrade/static\" class=\"code-anchor\">static</a> <span class=\"member-name\">stripTrailingSlash</span>: (url: string) => string</code>\n </td>\n <td>\n \n <p>Removes a trailing slash from a URL string if needed.\nLooks for the first occurrence of either <code>#</code>, <code>?</code>, or the end of the\nline as <code>/</code> characters and removes the trailing slash if one exists.</p>\n\n \n </td>\n </tr>\n \n </tbody>\n </table>\n</section>\n\n\n\n\n\n\n\n\n\n\n\n<section class=\"instance-methods\">\n <h2 id=\"methods\">Methods<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#methods\"><i class=\"material-icons\">link</i></a></h2>\n \n <a id=\"path\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"path\">\n path()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#path\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L84-L96\" 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/common/src/location/location.ts#L84-L96\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Normalizes the URL path for this location.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">path</span>(includeHash: boolean = false): string</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>includeHash</code>\n </td>\n <td class=\"param-type\"><code>boolean</code></td>\n <td class=\"param-description\">\n <p>True to include an anchor fragment in the path.</p>\n<p> Optional. Default is <code>false</code>.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns\">Returns</h6>\n <p><code>string</code>: The normalized URL path.</p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"getState\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"getstate\">\n getState()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#getstate\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L97-L104\" 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/common/src/location/location.ts#L97-L104\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Reports the current state of the location history.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">getState</span>(): unknown</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-1\">Parameters</h6>\n <p>There are no parameters.</p>\n\n \n <h6 class=\"no-anchor\" id=\"returns-1\">Returns</h6>\n <p><code>unknown</code>: The current value of the <code>history.state</code> object.</p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"isCurrentPathEqualTo\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"iscurrentpathequalto\">\n isCurrentPathEqualTo()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#iscurrentpathequalto\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L105-L117\" 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/common/src/location/location.ts#L105-L117\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Normalizes the given path and compares to the current normalized path.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">isCurrentPathEqualTo</span>(path: string, <a href=\"api/animations/query\" class=\"code-anchor\">query</a>: string = ''): boolean</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-2\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>path</code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>The given URL path.</p>\n\n </td>\n </tr>\n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code><a href=\"api/animations/query\" class=\"code-anchor\">query</a></code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>Query parameters.</p>\n<p> Optional. Default is <code>''</code>.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns-2\">Returns</h6>\n <p><code>boolean</code>: True if the given URL path is equal to the current normalized path, false\notherwise.</p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"normalize\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"normalize\">\n normalize()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#normalize\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L118-L128\" 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/common/src/location/location.ts#L118-L128\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Normalizes a URL path by stripping any trailing slashes.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">normalize</span>(url: string): string</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-3\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>url</code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>String representing a URL.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns-3\">Returns</h6>\n <p><code>string</code>: The normalized URL string.</p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"prepareExternalUrl\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"prepareexternalurl\">\n prepareExternalUrl()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#prepareexternalurl\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L129-L145\" 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/common/src/location/location.ts#L129-L145\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Normalizes an external URL path.\nIf the given URL doesn't begin with a leading slash (<code>'/'</code>), adds one\nbefore normalizing. Adds a hash if <code><a href=\"api/common/HashLocationStrategy\" class=\"code-anchor\">HashLocationStrategy</a></code> is\nin use, or the <code><a href=\"api/common/APP_BASE_HREF\" class=\"code-anchor\">APP_BASE_HREF</a></code> if the <code><a href=\"api/common/PathLocationStrategy\" class=\"code-anchor\">PathLocationStrategy</a></code> is in use.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">prepareExternalUrl</span>(url: string): string</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-4\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>url</code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>String representing a URL.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns-4\">Returns</h6>\n <p><code>string</code>: A normalized platform-specific URL.</p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"go\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"go\">\n go()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#go\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L146-L161\" 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/common/src/location/location.ts#L146-L161\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Changes the browser's URL to a normalized version of a given URL, and pushes a\nnew item onto the platform's history.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">go</span>(path: string, <a href=\"api/animations/query\" class=\"code-anchor\">query</a>: string = '', <a href=\"api/animations/state\" class=\"code-anchor\">state</a>: any = null): void</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-5\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>path</code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>URL path to normalize.</p>\n\n </td>\n </tr>\n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code><a href=\"api/animations/query\" class=\"code-anchor\">query</a></code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>Query parameters.</p>\n<p> Optional. Default is <code>''</code>.</p>\n\n </td>\n </tr>\n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code><a href=\"api/animations/state\" class=\"code-anchor\">state</a></code>\n </td>\n <td class=\"param-type\"><code>any</code></td>\n <td class=\"param-description\">\n <p>Location history state.</p>\n<p> Optional. Default is <code>null</code>.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns-5\">Returns</h6>\n <p><code>void</code></p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"replaceState\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"replacestate\">\n replaceState()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#replacestate\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L162-L175\" 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/common/src/location/location.ts#L162-L175\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Changes the browser's URL to a normalized version of the given URL, and replaces\nthe top item on the platform's history stack.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">replaceState</span>(path: string, <a href=\"api/animations/query\" class=\"code-anchor\">query</a>: string = '', <a href=\"api/animations/state\" class=\"code-anchor\">state</a>: any = null): void</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-6\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>path</code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>URL path to normalize.</p>\n\n </td>\n </tr>\n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code><a href=\"api/animations/query\" class=\"code-anchor\">query</a></code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>Query parameters.</p>\n<p> Optional. Default is <code>''</code>.</p>\n\n </td>\n </tr>\n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code><a href=\"api/animations/state\" class=\"code-anchor\">state</a></code>\n </td>\n <td class=\"param-type\"><code>any</code></td>\n <td class=\"param-description\">\n <p>Location history state.</p>\n<p> Optional. Default is <code>null</code>.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns-6\">Returns</h6>\n <p><code>void</code></p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"forward\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"forward\">\n forward()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#forward\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L176-L182\" 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/common/src/location/location.ts#L176-L182\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Navigates forward in the platform's history.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">forward</span>(): void</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-7\">Parameters</h6>\n <p>There are no parameters.</p>\n\n \n <h6 class=\"no-anchor\" id=\"returns-7\">Returns</h6>\n <p><code>void</code></p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"back\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"back\">\n back()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#back\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L183-L189\" 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/common/src/location/location.ts#L183-L189\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Navigates back in the platform's history.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">back</span>(): void</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-8\">Parameters</h6>\n <p>There are no parameters.</p>\n\n \n <h6 class=\"no-anchor\" id=\"returns-8\">Returns</h6>\n <p><code>void</code></p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"onUrlChange\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"onurlchange\">\n onUrlChange()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#onurlchange\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L190-L205\" 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/common/src/location/location.ts#L190-L205\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Registers a URL change listener. Use to catch updates performed by the Angular\nframework that are not detectible through \"popstate\" or \"hashchange\" events.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">onUrlChange</span>(fn: (url: string, <a href=\"api/animations/state\" class=\"code-anchor\">state</a>: unknown) => void)</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-9\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>fn</code>\n </td>\n <td class=\"param-type\"><code>(url: string, <a href=\"api/animations/state\" class=\"code-anchor\">state</a>: unknown) => void</code></td>\n <td class=\"param-description\">\n <p>The change handler function, which take a URL and a location history state.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"subscribe\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"subscribe\">\n subscribe()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#subscribe\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L211-L224\" 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/common/src/location/location.ts#L211-L224\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Subscribes to the platform's <code>popState</code> events.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">subscribe</span>(onNext: (value: <a href=\"api/common/PopStateEvent\" class=\"code-anchor\">PopStateEvent</a>) => void, onThrow?: (exception: any) => void, onReturn?: () => void): SubscriptionLike</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-10\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>onNext</code>\n </td>\n <td class=\"param-type\"><code>(value: <a href=\"api/common/PopStateEvent\" class=\"code-anchor\">PopStateEvent</a>) => void</code></td>\n <td class=\"param-description\">\n \n \n </td>\n </tr>\n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>onThrow</code>\n </td>\n <td class=\"param-type\"><code>(exception: any) => void</code></td>\n <td class=\"param-description\">\n <p>Optional. Default is <code>undefined</code>.</p>\n \n </td>\n </tr>\n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>onReturn</code>\n </td>\n <td class=\"param-type\"><code>() => void</code></td>\n <td class=\"param-description\">\n <p>Optional. Default is <code>undefined</code>.</p>\n \n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns-9\">Returns</h6>\n <p><code>SubscriptionLike</code>: Subscribed events.</p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n</section>\n\n\n\n \n<section class=\"usage-notes\">\n <h2 id=\"usage-notes\">Usage notes<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#usage-notes\"><i class=\"material-icons\">link</i></a></h2>\n <p>It's better to use the <code><a href=\"api/router/Router\" class=\"code-anchor\">Router</a>#navigate</code> service to trigger route changes. Use\n<code><a href=\"api/common/Location\" class=\"code-anchor\">Location</a></code> only if you need to interact with or create normalized URLs outside of\nrouting.</p>\n<p><code><a href=\"api/common/Location\" class=\"code-anchor\">Location</a></code> is responsible for normalizing the URL against the application's base href.\nA normalized URL is absolute from the URL host, includes the application's base href, and has no\ntrailing slash:</p>\n<ul>\n<li><code>/my/app/user/123</code> is normalized</li>\n<li><code>my/app/user/123</code> <strong>is not</strong> normalized</li>\n<li><code>/my/app/user/123/</code> <strong>is not</strong> normalized</li>\n</ul>\n<h3 id=\"example\">Example<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/Location#example\"><i class=\"material-icons\">link</i></a></h3>\n<code-example path=\"common/location/ts/path_location_component.ts\" region=\"LocationComponent\">\nimport {<a href=\"api/common/Location\" class=\"code-anchor\">Location</a>, <a href=\"api/common/LocationStrategy\" class=\"code-anchor\">LocationStrategy</a>, <a href=\"api/common/PathLocationStrategy\" class=\"code-anchor\">PathLocationStrategy</a>} from '@angular/common';\nimport {<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>} from '@angular/core';\n\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'path-location',\n providers: [<a href=\"api/common/Location\" class=\"code-anchor\">Location</a>, {provide: <a href=\"api/common/LocationStrategy\" class=\"code-anchor\">LocationStrategy</a>, useClass: <a href=\"api/common/PathLocationStrategy\" class=\"code-anchor\">PathLocationStrategy</a>}],\n template: `\n <h1><a href=\"api/common/PathLocationStrategy\" class=\"code-anchor\">PathLocationStrategy</a></h1>\n Current URL is: <code>{{location.path()}}</code><br>\n Normalize: <code>/foo/bar/</code> is: <code>{{location.normalize('foo/bar')}}</code><br>\n `\n})\nexport class PathLocationComponent {\n location: <a href=\"api/common/Location\" class=\"code-anchor\">Location</a>;\n constructor(location: <a href=\"api/common/Location\" class=\"code-anchor\">Location</a>) {\n this.location = location;\n }\n}\n\n</code-example>\n\n</section>\n\n\n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/common\n - api/common/HashLocationStrategy\n - api/common/LocationStrategy\n - api/common/PathLocationStrategy\n - api/common/PlatformLocation\n - api/common/testing\n - api/common/testing/SpyLocation\n - api/common/upgrade/$locationShim\n - api/common/upgrade/$locationShimProvider\n - api/core/FactoryProvider\n - api/router/Router\n - api/router/testing/RouterTestingModule\n - api/router/testing/setupTestingRouter\n - guide/universal\n - guide/upgrade\n - tutorial/toh-pt5\n - tutorial/toh-pt6\n-->\n<!-- links from this doc:\n - /api\n - api/animations/query\n - api/animations/state\n - api/common\n - api/common/APP_BASE_HREF\n - api/common/HashLocationStrategy\n - api/common/Location#back\n - api/common/Location#description\n - api/common/Location#example\n - api/common/Location#forward\n - api/common/Location#getState\n - api/common/Location#getstate\n - api/common/Location#go\n - api/common/Location#isCurrentPathEqualTo\n - api/common/Location#iscurrentpathequalto\n - api/common/Location#joinWithSlash\n - api/common/Location#location\n - api/common/Location#methods\n - api/common/Location#normalize\n - api/common/Location#normalizeQueryParams\n - api/common/Location#onUrlChange\n - api/common/Location#onurlchange\n - api/common/Location#path\n - api/common/Location#prepareExternalUrl\n - api/common/Location#prepareexternalurl\n - api/common/Location#replaceState\n - api/common/Location#replacestate\n - api/common/Location#static-properties\n - api/common/Location#stripTrailingSlash\n - api/common/Location#subclasses\n - api/common/Location#subscribe\n - api/common/Location#usage-notes\n - api/common/LocationStrategy\n - api/common/PathLocationStrategy\n - api/common/PopStateEvent\n - api/common/testing/SpyLocation\n - api/core/Component\n - api/router/Router\n - api/upgrade/static\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L105-L117\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L118-L128\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L129-L145\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L146-L161\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L162-L175\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L176-L182\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L183-L189\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L190-L205\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L211-L224\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L22-L256\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L84-L96\n - https://github.com/angular/angular/edit/master/packages/common/src/location/location.ts?message=docs(common)%3A%20describe%20your%20change...#L97-L104\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L105-L117\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L118-L128\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L129-L145\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L146-L161\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L162-L175\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L176-L182\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L183-L189\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L190-L205\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L211-L224\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L22-L256\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L84-L96\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/location/location.ts#L97-L104\n-->"
|
|
} |