# Class Location`Abstract`

#### Hierarchy (View Summary)

- Location
  - LocationHtml5Url
  - LocationHashbangUrl

- Defined in src/core/location/location.js:49

##### Index

### Constructors

constructor

### Properties

$$absUrl
$$hash
$$host
$$html5
$$path
$$port
$$protocol
$$replace
$$search
$$state
$$url
$$urlUpdatedByLocation
appBase
appBaseNoFile

### Methods

$$compose
$$normalizeUrl
$$parse
$$parseLinkUrl
absUrl
hash
host
path
port
protocol
replace
search
state
url

## Constructors

### constructor

- new Location(appBase: string, appBaseNoFile: string): Location

  #### Parameters

  - appBase: string

    application base URL

  - appBaseNoFile: string

    application base URL stripped of any filename

  #### Returns Location

  - Defined in src/core/location/location.js:54

## Properties

### $$absUrl

$$absUrl: string

An absolute URL is the full URL, including protocol (http/https ), the optional subdomain (e.g. www ), domain (example.com), and path (which includes the directory and slug).

- Defined in src/core/location/location.js:67
- Defined in src/core/location/location.js:300

### $$hash

$$hash: string

The hash string, minus the hash symbol

- Defined in src/core/location/location.js:104
- Defined in src/core/location/location.js:238

### $$host

$$host: string

- Defined in src/core/location/location.js:85

### $$html5

$$html5: boolean

If html5 mode is enabled

- Defined in src/core/location/location.js:73

### $$path

$$path: string

The pathname, beginning with "/"

- Defined in src/core/location/location.js:98
- Defined in src/core/location/location.js:211

### $$port

$$port: number

The port, without ":"

- Defined in src/core/location/location.js:91

### $$protocol

$$protocol: HttpProtocol

- Defined in src/core/location/location.js:82

### $$replace

$$replace: boolean

Has any change been replacing?

- Defined in src/core/location/location.js:79
- Defined in src/core/location/location.js:248

### $$search

$$search: any

- Defined in src/core/location/location.js:266
- Defined in src/core/location/location.js:274

### $$state

$$state: any

- Defined in src/core/location/location.js:343

### $$url

$$url: string

- Defined in src/core/location/location.js:299

### $$urlUpdatedByLocation

$$urlUpdatedByLocation: boolean

Helper property for scope watch changes

- Defined in src/core/location/location.js:110
- Defined in src/core/location/location.js:301
- Defined in src/core/location/location.js:344

### appBase

appBase: string

- Defined in src/core/location/location.js:58

### appBaseNoFile

appBaseNoFile: string

- Defined in src/core/location/location.js:61

## Methods

### $$compose

- $$compose(): void

  Compose url and update `url` and `absUrl` property

  #### Returns void

  - Defined in src/core/location/location.js:298

### $$normalizeUrl

- $$normalizeUrl(_url: string): string

  #### Parameters

  - _url: string

  #### Returns string

  - Defined in src/core/location/location.js:308

### $$parse

- $$parse(_url: any): void

  #### Parameters

  - _url: any

  #### Returns void

  - Defined in src/core/location/location.js:357

### $$parseLinkUrl

- $$parseLinkUrl(_url: string, _url2: string): boolean

  #### Parameters

  - _url: string
  - _url2: string

  #### Returns boolean

  - Defined in src/core/location/location.js:353

### absUrl

- absUrl(): string

  Return full URL representation with all segments encoded according to rules specified in RFC 3986.

  #### Returns string

  full URL

  - Defined in src/core/location/location.js:119

### hash

- hash(hash: string | number): string | Location

  This method is getter / setter.

  Returns the hash fragment when called without any parameters.

  Changes the hash fragment when called with a parameter and returns `$location`.

      // given URL http://example.com/#/some/path?foo=bar&baz=xoxo#hashValue
      let hash = $location.hash();
      // => "hashValue"

  #### Parameters

  - hash: string | number

    New hash fragment

  #### Returns string | Location

  hash

  - Defined in src/core/location/location.js:233

### host

- host(): string

  This method is getter only.

  Return host of current URL.

  Note: compared to the non-AngularTS version `location.host` which returns `hostname:port`, this returns the `hostname` portion only.

  #### Returns string

  host of current URL.

  - Defined in src/core/location/location.js:164

### path

- path(path: string | number): any

  This method is getter / setter.

  Return path of current URL when called without any parameter.

  Change path when called with parameter and return `$location`.

  Note: Path should always begin with forward slash (/), this method will add the forward slash if it is missing.

      // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
      let path = $location.path();
      // => "/some/path"

  #### Parameters

  - path: string | number

    New path

  #### Returns any

  path if called with no parameters, or `$location` if called with a parameter

  - Defined in src/core/location/location.js:206

### port

- port(): number

  This method is getter only.

  Return port of current URL.

      // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
      let port = $location.port();
      // => 80

  #### Returns number

  port

  - Defined in src/core/location/location.js:182

### protocol

- protocol(): HttpProtocol

  Return protocol of current URL.

  #### Returns HttpProtocol

  protocol of current URL

  - Defined in src/core/location/location.js:150

### replace

- replace(): Location

  If called, all changes to $location during the current `$digest` will replace the current history record, instead of adding a new one.

  #### Returns Location

  - Defined in src/core/location/location.js:247

### search

- search(
  search: any,
  paramValue: string | number | boolean | string[],
  ...args: any,
  ): any

  Returns or sets the search part (as object) of current URL when called without any parameter

  #### Parameters

  - search: any

    New search params - string or hash object.

  - paramValue: string | number | boolean | string[]

    If search is a string or number, then paramValue will override only a single search property.

  - ...args: any

  #### Returns any

  Search object or Location object

  - Defined in src/core/location/location.js:259

### state

- state(state: any, ...args: any): any

  This method is getter / setter.

  Return the history state object when called without any parameter.

  Change the history state object when called with one parameter and return `$location`. The state object is later passed to `pushState` or `replaceState`. See https://developer.mozilla.org/en-US/docs/Web/API/History/pushState#state|History.state

  NOTE: This method is supported only in HTML5 mode and only in browsers supporting the HTML5 History API (i.e. methods `pushState` and `replaceState`). If you need to support older browsers (like IE9 or Android < 4.0), don't use this method.

  #### Parameters

  - state: any

    State object for pushState or replaceState

  - ...args: any

  #### Returns any

  state

  - Defined in src/core/location/location.js:328

### url

- url(url: string): string | Location

  This method is getter / setter.

  Return URL (e.g. `/path?a=b#hash`) when called without any parameter. Change path, search and hash, when called with parameter and return `$location`.

  #### Parameters

  - url: string

    New URL without base prefix (e.g. `/path?a=b#hash`)

  #### Returns string | Location

  url

  - Defined in src/core/location/location.js:132