1
1
import { ContentSection } from '../models/content-section.model' ;
2
- import { ChangeDetectorRef , Component , Injector , Input , OnDestroy } from '@angular/core' ;
3
- import { ActivatedRoute , NavigationEnd , Router , NavigationExtras } from '@angular/router' ;
4
- import { Subscription } from 'rxjs' ;
2
+ import { ChangeDetectorRef , Component , Injector , Input } from '@angular/core' ;
3
+ import { Router , NavigationExtras } from '@angular/router' ;
5
4
6
5
const availableTabsPaths = [ 'overview' , 'api' , 'examples' ] as const ;
7
6
type AvailableTabsPathsType = typeof availableTabsPaths [ number ] ;
@@ -11,7 +10,7 @@ type AvailableTabsPathsType = typeof availableTabsPaths[number];
11
10
selector : 'docs-section' ,
12
11
13
12
template : `
14
- <ng-container *ngIf=" content">
13
+ @if ( content) {
15
14
<tabset class="example-tabset-box">
16
15
<tab heading="Overview" [customClass]="'example-tabset'" [active]="overview" (selectTab)="onSelect('overview')">
17
16
<ng-container *ngComponentOutlet="content[0].outlet; injector: sectionInjections(content[0])"></ng-container>
@@ -24,46 +23,22 @@ type AvailableTabsPathsType = typeof availableTabsPaths[number];
24
23
</tab>
25
24
</tabset>
26
25
<add-nav class="add-nav" [componentContent]="overview ? content[0] : api ? content[1] : content[2]"></add-nav>
27
- </ng-container>
26
+ }
28
27
` ,
29
28
standalone : false
30
29
} )
31
- export class DocsSectionComponent implements OnDestroy {
30
+ export class DocsSectionComponent {
32
31
@Input ( ) content : ContentSection [ ] | undefined ;
33
32
_injectors = new Map < ContentSection , Injector > ( ) ;
34
- routeSubscription : Subscription ;
35
33
overview = false ;
36
34
api = false ;
37
35
examples = false ;
38
36
39
37
constructor (
40
38
private injector : Injector ,
41
- private activatedRoute : ActivatedRoute ,
42
39
private router : Router ,
43
40
private changeDetection : ChangeDetectorRef
44
41
) {
45
- this . routeSubscription = this . router . events . subscribe ( ( event ) => {
46
- if ( event instanceof NavigationEnd ) {
47
- const params = this . router . parseUrl ( event . url ) . queryParams ;
48
- this . initActiveTab ( params [ 'tab' ] ?. toString ( ) ) ;
49
- }
50
- } ) ;
51
- }
52
-
53
- initActiveTab ( activeTab ?: string ) {
54
- this . resetTabs ( ) ;
55
- if ( ! activeTab || ! this . checkActiveTab ( activeTab ) ) {
56
- this . overview = true ;
57
- this . onSelect ( 'overview' ) ;
58
- return ;
59
- }
60
-
61
- this [ activeTab as AvailableTabsPathsType ] = true ;
62
- this . changeDetection . detectChanges ( ) ;
63
- }
64
-
65
- checkActiveTab ( activeTab : string ) : boolean {
66
- return activeTab === 'overview' || activeTab === 'api' || activeTab === 'examples' ;
67
42
}
68
43
69
44
onSelect ( tabName : string ) {
@@ -99,8 +74,4 @@ export class DocsSectionComponent implements OnDestroy {
99
74
this . api = false ;
100
75
this . examples = false ;
101
76
}
102
-
103
- ngOnDestroy ( ) {
104
- this . routeSubscription . unsubscribe ( ) ;
105
- }
106
77
}
0 commit comments