@@ -5,23 +5,14 @@ import {
5
5
ViewEncapsulation ,
6
6
forwardRef ,
7
7
inject ,
8
- input ,
9
8
viewChild ,
10
9
} from '@angular/core' ;
11
- import { toObservable } from '@angular/core/rxjs-interop' ;
12
10
import { BreakpointObserver } from '@angular/cdk/layout' ;
13
11
import { AsyncPipe } from '@angular/common' ;
14
12
import { MatListItem , MatNavList } from '@angular/material/list' ;
15
13
import { MatSidenav , MatSidenavContainer } from '@angular/material/sidenav' ;
16
- import {
17
- ActivatedRoute ,
18
- Params ,
19
- Routes ,
20
- RouterOutlet ,
21
- RouterLinkActive ,
22
- RouterLink ,
23
- } from '@angular/router' ;
24
- import { combineLatest , Observable , Subscription } from 'rxjs' ;
14
+ import { ActivatedRoute , Routes , RouterOutlet , RouterLinkActive , RouterLink } from '@angular/router' ;
15
+ import { Observable , of , Subscription } from 'rxjs' ;
25
16
import { map , switchMap } from 'rxjs/operators' ;
26
17
27
18
import { DocumentationItems } from '../../shared/documentation-items/documentation-items' ;
@@ -66,11 +57,9 @@ const SMALL_WIDTH_BREAKPOINT = 959;
66
57
} )
67
58
export class ComponentSidenav implements OnInit , OnDestroy {
68
59
docItems = inject ( DocumentationItems ) ;
69
- private _route = inject ( ActivatedRoute ) ;
70
60
private _navigationFocusService = inject ( NavigationFocusService ) ;
71
61
72
62
readonly sidenav = viewChild ( MatSidenav ) ;
73
- params : Observable < Params > ;
74
63
isExtraScreenSmall : Observable < boolean > ;
75
64
isScreenSmall : Observable < boolean > ;
76
65
private _subscriptions = new Subscription ( ) ;
@@ -84,11 +73,6 @@ export class ComponentSidenav implements OnInit, OnDestroy {
84
73
this . isScreenSmall = breakpoints
85
74
. observe ( `(max-width: ${ SMALL_WIDTH_BREAKPOINT } px)` )
86
75
. pipe ( map ( breakpoint => breakpoint . matches ) ) ;
87
-
88
- this . params = combineLatest (
89
- this . _route . pathFromRoot . map ( route => route . params ) ,
90
- Object . assign ,
91
- ) ;
92
76
}
93
77
94
78
ngOnInit ( ) {
@@ -120,12 +104,11 @@ export class ComponentSidenav implements OnInit, OnDestroy {
120
104
} )
121
105
export class ComponentNav {
122
106
private _docItems = inject ( DocumentationItems ) ;
123
- readonly params = input < Params | null > ( ) ;
107
+ private _route = inject ( ActivatedRoute ) ;
108
+ protected _params = this . _route . params ;
124
109
125
- items = toObservable ( this . params ) . pipe (
126
- switchMap ( params =>
127
- params ?. section ? this . _docItems . getItems ( params . section ) : Promise . resolve ( null ) ,
128
- ) ,
110
+ items = this . _params . pipe (
111
+ switchMap ( params => ( params ?. section ? this . _docItems . getItems ( params . section ) : of ( [ ] ) ) ) ,
129
112
) ;
130
113
}
131
114
0 commit comments