Skip to content

Commit

Permalink
88. Optimizaciones del Breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
florius88 committed Nov 21, 2023
1 parent bf25b74 commit b9ce3b0
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/app/shared/breadcrumbs/breadcrumbs.component.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
import { Component } from '@angular/core';
import { ActivationEnd, Event, Router } from '@angular/router';
import { filter, map } from 'rxjs';
import { Component, OnDestroy } from '@angular/core';
import { ActivatedRoute, ActivationEnd, Event, Router } from '@angular/router';
import { Subscription, filter, map } from 'rxjs';

@Component({
selector: 'app-breadcrumbs',
templateUrl: './breadcrumbs.component.html',
styles: [
]
})
export class BreadcrumbsComponent {
export class BreadcrumbsComponent implements OnDestroy {

public titulo: string = ''
public tituloSubs$: Subscription

constructor(private router: Router) {
constructor(private router: Router, private route: ActivatedRoute) {

this.getArgumentosRuta()
this.tituloSubs$ = this.getArgumentosRuta()
.subscribe(({ titulo }) => {
this.titulo = titulo
document.title = `AdminPro - ${titulo}`
})

// console.log(route.snapshot.children[0].data);

}
ngOnDestroy(): void {
this.tituloSubs$.unsubscribe()
}

getArgumentosRuta() {

this.router.events
return this.router.events
.pipe(
filter((event: Event): event is ActivationEnd => event instanceof ActivationEnd),
filter((event: ActivationEnd) => event.snapshot.firstChild === null),
map((event: ActivationEnd) => event.snapshot.data),
)
.subscribe(({ titulo }) => {
this.titulo = titulo
document.title = `AdminPro - ${titulo}`
})

}

Expand Down

0 comments on commit b9ce3b0

Please sign in to comment.