HashLocationStrategy is a LocationStrategy used to configure the PlatformLocation service to represent its state in the hash fragment of the browser's URL.

For instance, if you call location.go('/foo'), the browser's URL will become example.com#/foo.

Example

import {Component, provide} from 'angular2/core';
import {
  Location,
  LocationStrategy,
  HashLocationStrategy
} from 'angular2/platform/common';
import {
  ROUTER_DIRECTIVES,
  ROUTER_PROVIDERS,
  RouteConfig
} from 'angular2/router';
 
@Component({directives: [ROUTER_DIRECTIVES]})
@RouteConfig([
 {...},
])
class AppCmp {
  constructor(location: Location) {
    location.go('/foo');
  }
}
 
bootstrap(AppCmp, [
  ROUTER_PROVIDERS,
  provide(LocationStrategy, {useClass: HashLocationStrategy})
]);
Inheritance
Annotations

Constructors

HashLocationStrategy(PlatformLocation _platformLocation, [ @ @ String _baseHref ])

Properties

hashCode → int

Get a hash code for this object.

read-only, inherited
runtimeType → Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) → bool

The equality operator.

inherited

Methods

back() → void

forward() → void

getBaseHref() → String

hash() → String

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
onPopState(EventListener fn) → void

path() → String

prepareExternalUrl(String internal) → String

pushState(state, String title, String path, String queryParams) → void

replaceState(state, String title, String path, String queryParams) → void

toString() → String

Returns a string representation of this object.

inherited