File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export {RouterLink} from './src/router/router_link';
1212export { RouteParams } from './src/router/instruction' ;
1313export { RouteRegistry } from './src/router/route_registry' ;
1414export { LocationStrategy } from './src/router/location_strategy' ;
15+ export { HashLocationStrategy } from './src/router/hash_location_strategy' ;
1516export { HTML5LocationStrategy } from './src/router/html5_location_strategy' ;
1617export { Location , appBaseHrefToken } from './src/router/location' ;
1718export { Pipeline } from './src/router/pipeline' ;
Original file line number Diff line number Diff line change 1+ import { DOM } from 'angular2/src/dom/dom_adapter' ;
2+ import { Injectable } from 'angular2/di' ;
3+ import { LocationStrategy } from './location_strategy' ;
4+ import { EventListener , History , Location } from 'angular2/src/facade/browser' ;
5+
6+ @Injectable ( )
7+ export class HashLocationStrategy extends LocationStrategy {
8+ private _location : Location ;
9+ private _history : History ;
10+
11+ constructor ( ) {
12+ super ( ) ;
13+ this . _location = DOM . getLocation ( ) ;
14+ this . _history = DOM . getHistory ( ) ;
15+ }
16+
17+ onPopState ( fn : EventListener ) : void {
18+ DOM . getGlobalEventTarget ( 'window' ) . addEventListener ( 'popstate' , fn , false ) ;
19+ }
20+
21+ getBaseHref ( ) : string { return '' ; }
22+
23+ path ( ) : string { return this . _location . hash ; }
24+
25+ pushState ( state : any , title : string , url : string ) {
26+ this . _history . pushState ( state , title , '#' + url ) ;
27+ }
28+
29+ forward ( ) : void { this . _history . forward ( ) ; }
30+
31+ back ( ) : void { this . _history . back ( ) ; }
32+ }
You can’t perform that action at this time.
0 commit comments