1
|
/**
|
2
|
* @license
|
3
|
* Copyright Google Inc. All Rights Reserved.
|
4
|
*
|
5
|
* Use of this source code is governed by an MIT-style license that can be
|
6
|
* found in the LICENSE file at https://angular.io/license
|
7
|
*/
|
8
|
import { InjectionToken } from '@angular/core';
|
9
|
/**
|
10
|
* This class should not be used directly by an application developer. Instead, use
|
11
|
* {@link Location}.
|
12
|
*
|
13
|
* `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform
|
14
|
* agnostic.
|
15
|
* This means that we can have different implementation of `PlatformLocation` for the different
|
16
|
* platforms that angular supports. For example, `@angular/platform-browser` provides an
|
17
|
* implementation specific to the browser environment, while `@angular/platform-webworker` provides
|
18
|
* one suitable for use with web workers.
|
19
|
*
|
20
|
* The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy}
|
21
|
* when they need to interact with the DOM apis like pushState, popState, etc...
|
22
|
*
|
23
|
* {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly
|
24
|
* by the {@link Router} in order to navigate between routes. Since all interactions between {@link
|
25
|
* Router} /
|
26
|
* {@link Location} / {@link LocationStrategy} and DOM apis flow through the `PlatformLocation`
|
27
|
* class they are all platform independent.
|
28
|
*
|
29
|
* @stable
|
30
|
*/
|
31
|
export declare abstract class PlatformLocation {
|
32
|
abstract getBaseHrefFromDOM(): string;
|
33
|
abstract onPopState(fn: LocationChangeListener): void;
|
34
|
abstract onHashChange(fn: LocationChangeListener): void;
|
35
|
readonly abstract pathname: string;
|
36
|
readonly abstract search: string;
|
37
|
readonly abstract hash: string;
|
38
|
abstract replaceState(state: any, title: string, url: string): void;
|
39
|
abstract pushState(state: any, title: string, url: string): void;
|
40
|
abstract forward(): void;
|
41
|
abstract back(): void;
|
42
|
}
|
43
|
/**
|
44
|
* @whatItDoes indicates when a location is initialized
|
45
|
* @experimental
|
46
|
*/
|
47
|
export declare const LOCATION_INITIALIZED: InjectionToken<Promise<any>>;
|
48
|
/**
|
49
|
* A serializable version of the event from onPopState or onHashChange
|
50
|
*
|
51
|
* @experimental
|
52
|
*/
|
53
|
export interface LocationChangeEvent {
|
54
|
type: string;
|
55
|
}
|
56
|
/**
|
57
|
* @experimental
|
58
|
*/
|
59
|
export interface LocationChangeListener {
|
60
|
(e: LocationChangeEvent): any;
|
61
|
}
|