1
1
import { Component , Input , OnInit } from '@angular/core' ;
2
2
import { Http } from '@angular/http' ;
3
3
import { Router , NavigationExtras } from '@angular/router' ;
4
- import { DocInfoService } from '../../../../shared ' ;
4
+ import { DocInfoService , NgLang } from '../doc-info.service ' ;
5
5
import 'rxjs/add/operator/toPromise' ;
6
6
7
7
type Lang = 'dart' | 'ts' | 'js' ;
@@ -58,23 +58,21 @@ export class ApiListComponent implements OnInit {
58
58
59
59
constructor (
60
60
private http : Http ,
61
- private router : Router ,
62
61
private docInfoSvc : DocInfoService
63
62
) {
64
- router . events . subscribe ( ( event ) => {
65
- this . applyFilterOnSections ( ) ;
66
- } ) ;
63
+ this . applyFilterOnSections ( ) ;
64
+ // router.events.subscribe((event) => { ... });
67
65
}
68
66
69
67
get ngLang ( ) { return this . docInfoSvc . ngLang ; }
70
68
71
69
ngOnInit ( ) : void {
72
- const urlPrefix = this . router . url . split ( '?' ) [ 0 ] . replace ( / ^ \/ d o c s \/ / , '/assets/' ) ;
70
+ const urlPrefix = this . docInfoSvc . path . split ( '?' ) [ 0 ] ; // .replace(/^\/docs\//, '/assets/');
73
71
const url = `${ urlPrefix } /${ this . src } ` ;
74
72
this . fetchUrl ( url ) ;
75
73
76
74
// extract type and status from url
77
- var split = this . router . url . split ( '?' ) ;
75
+ var split = this . docInfoSvc . path . split ( '?' ) ; // FIXME: path doesn't currently contain query params
78
76
if ( split . length > 1 ) {
79
77
const paramsRaw = split [ 1 ] . split ( '&' ) ;
80
78
const type = paramsRaw [ 0 ] ? paramsRaw [ 0 ] . split ( '=' ) [ 1 ] : '' ;
@@ -125,7 +123,7 @@ export class ApiListComponent implements OnInit {
125
123
126
124
applyFilterOnSections ( ) {
127
125
// Cannot guarantee that <param> in queryParam=<param> is an ApiMatch so we union type check it with a string.
128
- const selectedApiMatchOnUrl : string | ApiMatch = this . router . url . split ( '=' ) [ 1 ] ;
126
+ const selectedApiMatchOnUrl : string | ApiMatch = this . docInfoSvc . path . split ( '=' ) [ 1 ] ;
129
127
this . changeSelectedApiTypeForApiMatch ( selectedApiMatchOnUrl ) ;
130
128
if ( this . isApiLoaded ) {
131
129
this . groupedSections . forEach ( ( s ) => {
@@ -204,9 +202,7 @@ export class ApiListComponent implements OnInit {
204
202
status : status
205
203
}
206
204
} ;
207
-
208
- this . router . navigate ( [ `/docs/${ this . ngLang } /latest/api` ] , navigationExtras ) ;
209
-
205
+ // FIXME, was: this.router.navigate([`/docs/${this.ngLang}/latest/api`], navigationExtras);
210
206
this . toggleApiMenu ( ) ;
211
207
}
212
208
@@ -222,9 +218,7 @@ export class ApiListComponent implements OnInit {
222
218
status : status
223
219
}
224
220
} ;
225
-
226
- this . router . navigate ( [ `/docs/${ this . ngLang } /latest/api` ] , navigationExtras ) ;
227
-
221
+ // FIXME, was: this.router.navigate([`/docs/${this.ngLang}/latest/api`], navigationExtras);
228
222
this . toggleStatusMenu ( ) ;
229
223
}
230
224
@@ -236,7 +230,4 @@ export class ApiListComponent implements OnInit {
236
230
this . showStatusMenu = ! this . showStatusMenu ;
237
231
}
238
232
239
- clearType ( ) {
240
-
241
- }
242
233
}
0 commit comments