|
1 | 1 | import {Promise, PromiseWrapper, EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; |
2 | 2 | import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection'; |
3 | | -import {isBlank, isPresent, Type} from 'angular2/src/facade/lang'; |
| 3 | +import {isBlank, isPresent, Type, isArray} from 'angular2/src/facade/lang'; |
4 | 4 |
|
5 | 5 | import {RouteRegistry} from './route_registry'; |
6 | 6 | import {Pipeline} from './pipeline'; |
@@ -28,25 +28,19 @@ import {Location} from './location'; |
28 | 28 | * @exportedAs angular2/router |
29 | 29 | */ |
30 | 30 | export class Router { |
31 | | - navigating: boolean; |
| 31 | + navigating: boolean = false; |
32 | 32 | lastNavigationAttempt: string; |
33 | | - previousUrl: string; |
| 33 | + previousUrl: string = null; |
| 34 | + |
| 35 | + private _currentInstruction: Instruction = null; |
| 36 | + private _currentNavigation: Promise<any> = PromiseWrapper.resolve(true); |
| 37 | + private _outlet: RouterOutlet = null; |
| 38 | + private _subject: EventEmitter = new EventEmitter(); |
34 | 39 |
|
35 | | - private _currentInstruction: Instruction; |
36 | | - private _currentNavigation: Promise<any>; |
37 | | - private _outlet: RouterOutlet; |
38 | | - private _subject: EventEmitter; |
39 | 40 | // todo(jeffbcross): rename _registry to registry since it is accessed from subclasses |
40 | 41 | // todo(jeffbcross): rename _pipeline to pipeline since it is accessed from subclasses |
41 | 42 | constructor(public _registry: RouteRegistry, public _pipeline: Pipeline, public parent: Router, |
42 | | - public hostComponent: any) { |
43 | | - this.navigating = false; |
44 | | - this.previousUrl = null; |
45 | | - this._outlet = null; |
46 | | - this._subject = new EventEmitter(); |
47 | | - this._currentInstruction = null; |
48 | | - this._currentNavigation = PromiseWrapper.resolve(true); |
49 | | - } |
| 43 | + public hostComponent: any) {} |
50 | 44 |
|
51 | 45 |
|
52 | 46 | /** |
@@ -88,8 +82,8 @@ export class Router { |
88 | 82 | * ]); |
89 | 83 | * ``` |
90 | 84 | */ |
91 | | - config(config: any): Promise<any> { |
92 | | - if (config instanceof List) { |
| 85 | + config(config: StringMap<string, any>| List<StringMap<string, any>>): Promise<any> { |
| 86 | + if (isArray(config)) { |
93 | 87 | (<List<any>>config) |
94 | 88 | .forEach((configObject) => { this._registry.config(this.hostComponent, configObject); }); |
95 | 89 | } else { |
|
0 commit comments