Skip to content

Commit 4f83cab

Browse files
committed
style: fix breadcrumbs ts errors
1 parent f798077 commit 4f83cab

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
21
<ol class="breadcrumb">
32
<li *ngFor="let breadcrumb of breadcrumbs; let first = first; let last = last" [class.active]="last || !breadcrumb.url">
43
<a *ngIf="breadcrumb.url && !last; else noLink" [routerLink]="breadcrumb.url">
54
<i *ngIf="first" ngClass="{{homeIcon}}"></i>
65
<ng-template [ngIf]="breadcrumb.data.breadcrumbs">{{breadcrumb.data.breadcrumbs}}</ng-template>
7-
<ng-template [ngIf]="!breadcrumb.data.breadcrumbs">{{breadcrumb.data.title}}</ng-template>
6+
<ng-template [ngIf]="breadcrumb.data.title">{{breadcrumb.data.title}}</ng-template>
87
</a>
98
<ng-template #noLink>
109
<i *ngIf="first" ngClass="{{homeIcon}}"></i>
1110
<ng-template [ngIf]="breadcrumb.data.breadcrumbs">{{breadcrumb.data.breadcrumbs}}</ng-template>
12-
<ng-template [ngIf]="!breadcrumb.data.breadcrumbs">{{breadcrumb.data.title}}</ng-template>
11+
<ng-template [ngIf]="breadcrumb.data.title">{{breadcrumb.data.title}}</ng-template>
1312
</ng-template>
1413
</li>
1514
</ol>
Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,44 @@
11
import { Component, OnInit, Input, OnDestroy, ChangeDetectorRef } from '@angular/core';
2+
23
import { Subscription } from 'rxjs';
34

45
import { Path, RoutingService } from '../services/routing.service';
56

6-
export interface Breadcrumb extends Path {
7+
8+
export interface Breadcrumbs extends Path {
79
data: {
810
breadcrumbs?: string;
9-
title?: string;
11+
title?: string
1012
};
1113
}
1214

13-
/*
14-
*
15-
*/
15+
1616
@Component({
1717
selector: 'mk-breadcrumbs',
1818
templateUrl: './breadcrumbs.component.html',
1919
styleUrls: ['./breadcrumbs.component.css']
2020
})
2121
export class BreadcrumbsComponent implements OnInit, OnDestroy {
22-
public breadcrumbs?: Breadcrumb[];
22+
@Input() public homeIcon = 'fa fa-home';
2323

24-
private subscription!: Subscription;
24+
public breadcrumbs?: Breadcrumbs [];
2525

26-
@Input() public homeIcon = 'fa fa-home';
26+
private subscription?: Subscription;
2727

28-
/**
29-
* @method constructor
30-
* @param routingService [description]
31-
* @param changeDetectorRef [description]
32-
*/
3328
constructor(
3429
private routingService: RoutingService,
3530
private changeDetectorRef: ChangeDetectorRef
3631
) {}
3732

38-
/**
39-
* @method ngOnInit
40-
*/
4133
ngOnInit(): void {
4234
this.subscription = this.routingService.onChange.subscribe(paths => {
4335
this.breadcrumbs = paths;
4436
});
4537
}
4638

47-
/**
48-
* @method ngOnDestroy
49-
*/
5039
ngOnDestroy(): void {
51-
this.subscription.unsubscribe();
40+
if (this.subscription) {
41+
this.subscription.unsubscribe();
42+
}
5243
}
5344
}

0 commit comments

Comments
 (0)