-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<nz-breadcrumb> | ||
<nz-breadcrumb-item> | ||
<a routerLink="/">Home</a> | ||
</nz-breadcrumb-item> | ||
<nz-breadcrumb-item *ngFor="let breadcrumb of breadcrumbs"> | ||
<a [routerLink]="breadcrumb.url">{{ breadcrumb.label }}</a> | ||
</nz-breadcrumb-item> | ||
</nz-breadcrumb> |
Empty file.
23 changes: 23 additions & 0 deletions
23
src/app/components/bread-crump/bread-crump.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { BreadCrumpComponent } from './bread-crump.component'; | ||
|
||
describe('BreadCrumpComponent', () => { | ||
let component: BreadCrumpComponent; | ||
let fixture: ComponentFixture<BreadCrumpComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [BreadCrumpComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(BreadCrumpComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { NgFor, NgIf } from '@angular/common'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute, NavigationEnd, Router, RouterLink } from '@angular/router'; | ||
import { NzBreadCrumbComponent, NzBreadCrumbItemComponent } from 'ng-zorro-antd/breadcrumb'; | ||
import { filter } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-bread-crump', | ||
standalone: true, | ||
imports: [NzBreadCrumbComponent, NzBreadCrumbItemComponent, NgIf, NgFor, RouterLink], | ||
templateUrl: './bread-crump.component.html', | ||
styleUrl: './bread-crump.component.scss', | ||
}) | ||
export class BreadCrumpComponent implements OnInit { | ||
breadcrumbs: Array<{label: string, url: string}> = []; | ||
|
||
constructor(private router: Router) {} | ||
|
||
ngOnInit() { | ||
this.router.events.pipe( | ||
filter(event => event instanceof NavigationEnd) | ||
).subscribe(() => { | ||
this.generateBreadcrumbs(); | ||
}); | ||
|
||
this.generateBreadcrumbs(); | ||
} | ||
|
||
private generateBreadcrumbs() { | ||
const urlParts = this.router.url.split('/').filter(part => part); | ||
this.breadcrumbs = urlParts.map((part, index) => { | ||
const url = '/' + urlParts.slice(0, index + 1).join('/'); | ||
const label = this.formatLabel(part); | ||
return { label, url }; | ||
}); | ||
} | ||
|
||
private formatLabel(part: string): string { | ||
part = part.split('?')[0]; | ||
return part.charAt(0).toUpperCase() + part.slice(1).replace(/-/g, ' '); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/app/components/edit-user-components/edit-user/edit-user.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/app/components/manage-users-components/users-table/users-table.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters