@@ -5,23 +5,14 @@ import {
55 ViewEncapsulation ,
66 forwardRef ,
77 inject ,
8- input ,
98 viewChild ,
109} from '@angular/core' ;
11- import { toObservable } from '@angular/core/rxjs-interop' ;
1210import { BreakpointObserver } from '@angular/cdk/layout' ;
1311import { AsyncPipe } from '@angular/common' ;
1412import { MatListItem , MatNavList } from '@angular/material/list' ;
1513import { 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' ;
2516import { map , switchMap } from 'rxjs/operators' ;
2617
2718import { DocumentationItems } from '../../shared/documentation-items/documentation-items' ;
@@ -66,11 +57,9 @@ const SMALL_WIDTH_BREAKPOINT = 959;
6657} )
6758export class ComponentSidenav implements OnInit , OnDestroy {
6859 docItems = inject ( DocumentationItems ) ;
69- private _route = inject ( ActivatedRoute ) ;
7060 private _navigationFocusService = inject ( NavigationFocusService ) ;
7161
7262 readonly sidenav = viewChild ( MatSidenav ) ;
73- params : Observable < Params > ;
7463 isExtraScreenSmall : Observable < boolean > ;
7564 isScreenSmall : Observable < boolean > ;
7665 private _subscriptions = new Subscription ( ) ;
@@ -84,11 +73,6 @@ export class ComponentSidenav implements OnInit, OnDestroy {
8473 this . isScreenSmall = breakpoints
8574 . observe ( `(max-width: ${ SMALL_WIDTH_BREAKPOINT } px)` )
8675 . pipe ( map ( breakpoint => breakpoint . matches ) ) ;
87-
88- this . params = combineLatest (
89- this . _route . pathFromRoot . map ( route => route . params ) ,
90- Object . assign ,
91- ) ;
9276 }
9377
9478 ngOnInit ( ) {
@@ -120,12 +104,11 @@ export class ComponentSidenav implements OnInit, OnDestroy {
120104} )
121105export class ComponentNav {
122106 private _docItems = inject ( DocumentationItems ) ;
123- readonly params = input < Params | null > ( ) ;
107+ private _route = inject ( ActivatedRoute ) ;
108+ protected _params = this . _route . params ;
124109
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 ( [ ] ) ) ) ,
129112 ) ;
130113}
131114
0 commit comments