PlatformLocation

PlatformLocation

Stable Class

Class Overview

class PlatformLocation {
  getBaseHrefFromDOM() : string
  onPopState(fn: LocationChangeListener) : void
  onHashChange(fn: LocationChangeListener) : void
  pathname : string
  search : string
  hash : string
  replaceState(state: any, title: string, url: string) : void
  pushState(state: any, title: string, url: string) : void
  forward() : void
  back() : void
}

Class Description

This class should not be used directly by an application developer. Instead, use Location.

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 BrowserPlatformLocation, however when you run your app in a WebWorker you use WebWorkerPlatformLocation.

The PlatformLocation class is used directly by all implementations of LocationStrategy when they need to interact with the DOM apis like pushState, popState, etc...

LocationStrategy in turn is used by the Location service which is used directly by the Router in order to navigate between routes. Since all interactions between Router / Location / LocationStrategy and DOM apis flow through the PlatformLocation class they are all platform independent.

Class Details

getBaseHrefFromDOM() : string
onPopState(fn: LocationChangeListener) : void
onHashChange(fn: LocationChangeListener) : void
pathname : string
search : string
hash : string
replaceState(state: any, title: string, url: string) : void
pushState(state: any, title: string, url: string) : void
forward() : void
back() : void

exported from common-index, defined in common/src/location/platform_location.ts

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/docs/ts/latest/api/common/index/PlatformLocation-class.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部