-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
ngrx/platform
#3593Closed
Copy link
Description
Which @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
When the title is added as follows:
{
path: '',
component: HelloComponent,
title: 'HELLO',
}and we try to access it via route.snapshot.title:
export class HelloComponent implements OnInit {
constructor(private readonly route: ActivatedRoute) {}
ngOnInit(): void {
console.log(this.route.snapshot.title); // undefined
}
}it will be undefined. However, we can still get the route title from route.snapshot.data:
const routeTitleKey = Object
.getOwnPropertySymbols(this.route.snapshot.data)
.find((symbol) => symbol.toString() === 'Symbol(RouteTitle)');
console.log(this.route.snapshot.data[routeTitleKey]); // HELLOPlease provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/angular-ivy-hqjky1?file=src%2Fapp%2Fhello.component.ts
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version)
Angular 14.2.2
Anything else?
No response
Reactions are currently unavailable