2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2015-11-23 10:47:06 -08:00
|
|
|
/**
|
|
|
|
|
* This class should not be used directly by an application developer. Instead, use
|
|
|
|
|
* {@link Location}.
|
2016-01-21 09:58:28 -08:00
|
|
|
*
|
|
|
|
|
* `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform
|
|
|
|
|
* agnostic.
|
|
|
|
|
* This means that we can have different implementation of `PlatformLocation` for the different
|
|
|
|
|
* platforms
|
|
|
|
|
* that angular supports. For example, the default `PlatformLocation` is {@link
|
|
|
|
|
* BrowserPlatformLocation},
|
|
|
|
|
* however when you run your app in a WebWorker you use {@link WebWorkerPlatformLocation}.
|
|
|
|
|
*
|
|
|
|
|
* The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy}
|
|
|
|
|
* when
|
|
|
|
|
* they need to interact with the DOM apis like pushState, popState, etc...
|
|
|
|
|
*
|
|
|
|
|
* {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly
|
|
|
|
|
* by
|
|
|
|
|
* the {@link Router} in order to navigate between routes. Since all interactions between {@link
|
|
|
|
|
* Router} /
|
|
|
|
|
* {@link Location} / {@link LocationStrategy} and DOM apis flow through the `PlatformLocation`
|
|
|
|
|
* class
|
|
|
|
|
* they are all platform independent.
|
2016-05-27 11:24:05 -07:00
|
|
|
*
|
|
|
|
|
* @stable
|
2015-11-23 10:47:06 -08:00
|
|
|
*/
|
2016-01-21 09:58:28 -08:00
|
|
|
export abstract class PlatformLocation {
|
|
|
|
|
abstract getBaseHrefFromDOM(): string;
|
2016-08-23 14:26:31 -07:00
|
|
|
abstract onPopState(fn: LocationChangeListener): void;
|
|
|
|
|
abstract onHashChange(fn: LocationChangeListener): void;
|
2015-11-23 10:47:06 -08:00
|
|
|
|
2016-06-14 19:49:25 -07:00
|
|
|
get pathname(): string { return null; }
|
|
|
|
|
get search(): string { return null; }
|
|
|
|
|
get hash(): string { return null; }
|
2015-11-23 10:47:06 -08:00
|
|
|
|
2016-01-21 09:58:28 -08:00
|
|
|
abstract replaceState(state: any, title: string, url: string): void;
|
2015-11-23 10:47:06 -08:00
|
|
|
|
2016-01-21 09:58:28 -08:00
|
|
|
abstract pushState(state: any, title: string, url: string): void;
|
2015-11-23 10:47:06 -08:00
|
|
|
|
2016-01-21 09:58:28 -08:00
|
|
|
abstract forward(): void;
|
2015-11-23 10:47:06 -08:00
|
|
|
|
2016-01-21 09:58:28 -08:00
|
|
|
abstract back(): void;
|
|
|
|
|
}
|
2015-12-07 16:05:57 -08:00
|
|
|
|
2016-01-21 09:58:28 -08:00
|
|
|
/**
|
|
|
|
|
* A serializable version of the event from onPopState or onHashChange
|
2016-05-27 11:24:05 -07:00
|
|
|
*
|
2016-06-27 12:27:23 -07:00
|
|
|
* @experimental
|
2016-01-21 09:58:28 -08:00
|
|
|
*/
|
2016-08-23 14:26:31 -07:00
|
|
|
export interface LocationChangeEvent { type: string; }
|
2015-11-23 10:47:06 -08:00
|
|
|
|
2016-06-27 12:27:23 -07:00
|
|
|
/**
|
|
|
|
|
* @experimental
|
|
|
|
|
*/
|
2016-08-23 14:26:31 -07:00
|
|
|
export interface LocationChangeListener { (e: LocationChangeEvent): any; }
|