Please look at my code
{{ name$ | async | translate }}
@component({
Changedetction: Changedetction Strategy.Onpush, })
export class navcontainer extends Dropdown implements OnDestroy {
public name$: Observable<string> = this._routerService.getActivatedRouteName()
}
Service:
import { Injectable } from '@angular/core';
@Injectable({ providedIn: 'root', }) export class HeroService {
constructor( private _router: Router, private _activatedRoute:Activated route, ){}
public getactivatedRouteChildern(): Observable<Data>{
return this._router.events.pipe( filter (event => event instance of NavigationEnd), map(() => this._activatedRoute.snapshot), , expand (activatedRoute => of(activatedRoute.firstChild)), takewhile (Boolean)) }
Public getactivatedRouteName(): Observable<string>{
return this.getactivatedRouteChildern(). pipe (
last (),map(lastActivatedChildRoute => lastActivatedChildRoute.data.name), repeat ()) }
}
}
Router:
{ path:'' component:somecomponent,data:{ name:'COMM.NAME' ,hashelp: true}