parent
0a51ccbd68
commit
a67f2314f9
|
@ -12,6 +12,7 @@ export {RouterLink} from './src/router/router_link';
|
||||||
export {RouteParams} from './src/router/instruction';
|
export {RouteParams} from './src/router/instruction';
|
||||||
export {RouteRegistry} from './src/router/route_registry';
|
export {RouteRegistry} from './src/router/route_registry';
|
||||||
export {LocationStrategy} from './src/router/location_strategy';
|
export {LocationStrategy} from './src/router/location_strategy';
|
||||||
|
export {HashLocationStrategy} from './src/router/hash_location_strategy';
|
||||||
export {HTML5LocationStrategy} from './src/router/html5_location_strategy';
|
export {HTML5LocationStrategy} from './src/router/html5_location_strategy';
|
||||||
export {Location, appBaseHrefToken} from './src/router/location';
|
export {Location, appBaseHrefToken} from './src/router/location';
|
||||||
export {Pipeline} from './src/router/pipeline';
|
export {Pipeline} from './src/router/pipeline';
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||||
|
import {Injectable} from 'angular2/di';
|
||||||
|
import {LocationStrategy} from './location_strategy';
|
||||||
|
import {EventListener, History, Location} from 'angular2/src/facade/browser';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class HashLocationStrategy extends LocationStrategy {
|
||||||
|
private _location: Location;
|
||||||
|
private _history: History;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this._location = DOM.getLocation();
|
||||||
|
this._history = DOM.getHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
onPopState(fn: EventListener): void {
|
||||||
|
DOM.getGlobalEventTarget('window').addEventListener('popstate', fn, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
getBaseHref(): string { return ''; }
|
||||||
|
|
||||||
|
path(): string { return this._location.hash; }
|
||||||
|
|
||||||
|
pushState(state: any, title: string, url: string) {
|
||||||
|
this._history.pushState(state, title, '#' + url);
|
||||||
|
}
|
||||||
|
|
||||||
|
forward(): void { this._history.forward(); }
|
||||||
|
|
||||||
|
back(): void { this._history.back(); }
|
||||||
|
}
|
Loading…
Reference in New Issue