# Class LocationHashbangUrl

LocationHashbangUrl represents URL This object is exposed as $location service when developer doesn't opt into html5 mode. It also serves as the base class for html5 mode fallback on legacy browsers.

#### Param: appBase

application base URL

#### Param: appBaseNoFile

application base URL stripped of any filename

#### Param: hashPrefix

hashbang prefix

#### Hierarchy (View Summary)

- Location
  - LocationHashbangUrl

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

##### Index

### Constructors

constructor

### Properties

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

### Methods

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

## Constructors

### constructor

- new LocationHashbangUrl(
  appBase: any,
  appBaseNoFile: any,
  hashPrefix: any,
  ): LocationHashbangUrl

  #### Parameters

  - appBase: any
  - appBaseNoFile: any
  - hashPrefix: any

  #### Returns LocationHashbangUrl

  Overrides Location.constructor

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

## 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).

Inherited from Location.$$absUrl

- 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

Inherited from Location.$$hash

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

### $$host

$$host: string

Inherited from Location.$$host

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

### $$html5

$$html5: boolean

If html5 mode is enabled

Inherited from Location.$$html5

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

### $$path

$$path: string

The pathname, beginning with "/"

Inherited from Location.$$path

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

### $$port

$$port: number

The port, without ":"

Inherited from Location.$$port

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

### $$protocol

$$protocol: HttpProtocol

Inherited from Location.$$protocol

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

### $$replace

$$replace: boolean

Has any change been replacing?

Inherited from Location.$$replace

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

### $$search

$$search: any

Inherited from Location.$$search

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

### $$state

$$state: any

Inherited from Location.$$state

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

### $$url

$$url: string

Inherited from Location.$$url

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

### $$urlUpdatedByLocation

$$urlUpdatedByLocation: boolean

Helper property for scope watch changes

Inherited from Location.$$urlUpdatedByLocation

- 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

Inherited from Location.appBase

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

### appBaseNoFile

appBaseNoFile: string

Inherited from Location.appBaseNoFile

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

### hashPrefix

hashPrefix: any

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

## Methods

### $$compose

- $$compose(): void

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

  #### Returns void

  Inherited from Location.$$compose

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

### $$normalizeUrl

- $$normalizeUrl(url: any): string

  #### Parameters

  - url: any

  #### Returns string

  Overrides Location.$$normalizeUrl

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

### $$parse

- $$parse(url: string): void

  Parse given hashbang URL into properties

  #### Parameters

  - url: string

    Hashbang URL

  #### Returns void

  Overrides Location.$$parse

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

### $$parseLinkUrl

- $$parseLinkUrl(url: string): boolean

  #### Parameters

  - url: string

  #### Returns boolean

  Overrides Location.$$parseLinkUrl

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

### absUrl

- absUrl(): string

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

  #### Returns string

  full URL

  Inherited from Location.absUrl

  - 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

  Inherited from 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.

  Inherited from Location.host

  - 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

  Inherited from Location.path

  - 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

  Inherited from Location.port

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

### protocol

- protocol(): HttpProtocol

  Return protocol of current URL.

  #### Returns HttpProtocol

  protocol of current URL

  Inherited from Location.protocol

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

### replace

- replace(): LocationHashbangUrl

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

  #### Returns LocationHashbangUrl

  Inherited from Location.replace

  - 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

  Inherited from Location.search

  - 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

  Inherited from Location.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

  Inherited from Location.url

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