@angular/router: ActivatedRoute.snapshot.title is always undefined

This issue has been created since 2022-09-16.

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]); // HELLO

Please 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

atscott wrote this answer on 2022-09-21

Confirmed. This isn't working because the title is treated as resolved data, which is mutated on the snapshot and not available at the time of class creation. Fixing this will technically be a breaking change (since there's no way to have an optional getter function) so it won't be available until v15. In the meantime, you can use the Observable title on ActivatedRoute to get the correct value.

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-10-04
Star Count 84139
Watcher Count 3064
Fork Count 22243
Issue Count 1206

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Unable to stream more than 3 tracks in H264 encoding 0 2022-08-26 2022-09-25
bamCoverage ValueError: invalid literal for int() with base 10 2 2022-04-22 2022-08-17
There are accidents when correctGCBias meets bams with unusual tag 2 2021-06-01 2022-09-14
Could we have the contentType in the create result ? 7 2021-04-15 2022-10-02
Converter don't apply (all) updates on Linux 2 2021-02-01 2022-08-18
Badge type error when passing an icon 2 2022-03-11 2022-09-30
Test fails with unset `DISPLAY` environment variable Linux 1 2022-01-15 2022-09-17
Add PlatformIO Code Generation Support 4 2020-09-21 2022-08-31
feature request: enter repl when called 3 2022-04-18 2022-09-22
ReplMaker and OhMyREPL conflict 1 2021-01-10 2022-09-22
只能以未登录状态导入网易云歌单 11 2021-03-17 2021-12-29
Allow usage with write-only tokens 3 2021-09-24 2022-09-26
Update Portfolio / Add projects 0 2021-05-10 2021-12-23
max_batch_size=2, cuda out of memory 0 2022-07-15 2022-10-01
Eth Hashrate instable - 3070 LHR on Windows - driver Nvidia 496.76 6 2021-11-30 2022-10-01
How to add a Steam token? 1 2021-05-26 2022-10-04
No entries info not shown and entries missing 4 2021-05-26 2022-07-21
Markdown editor links should allow user to follow on mouse hover 0 2021-10-21 2022-09-27
unable to update collection 4 2022-07-26 2022-10-01
Rearchitect the AAD authentication code to be object oriented 0 2020-12-22 2022-09-30
Use utf-8 when latin encoding fails 2 2021-07-17 2022-09-09
CORS issue when using Google Fonts 2 2021-05-12 2022-09-18
Advanced Redstone Link - Redstone Link : Extension 1 2022-01-22 2022-10-02
New Rule: Prefer `LOWER(column) LIKE '%match%'` to `column ILIKE '%Match%'` 3 2022-01-21 2022-09-25
TypeError: _imgixCoreJs.default is not a constructor when running in Fastboot 3 2021-01-06 2022-09-30
[SUBMIT] How to auto populate data in Strapi using Python and Graphql 5 2021-09-29 2022-08-09
Getting serialization errors while trying to submit Qiskit Circuit List to distributed compute engine (DASK Client) of Qiskit Aer Simulator 1 2021-10-04 2022-09-21
when using --installroot, tdnf should search for the config files relative to it 0 2021-06-05 2022-10-01
Add Ordnance Survey as a provider 3 2020-09-28 2022-07-07
PROJECT: Update and doc apt-get for cli projects 0 2022-06-29 2022-09-21
PROJECT: Brew macOS and Debian support for all cli projects 0 2022-06-29 2022-09-21
Button in expanded panel 1 2019-08-01 2022-09-08
file uploads > 65536 characters, binary blobs/mp4s etc. 3 2019-01-05 2022-09-26
SystemUI: circle below the home button icon 2 2022-04-19 2022-09-18
405 (Method Not Allowed) 2 2021-08-24 2022-09-30
feat: Login dia code selection 1 2020-09-19 2022-09-21
will the share option on playlist repaired 1 2020-10-15 2022-09-16
Forward signals to child processes 16 2021-02-02 2022-09-25
load.cleanResults failes for different sensors front and back 0 2022-05-27 2022-08-20
LBNL RADIANCE 5.3 release 1 2022-05-31 2022-07-29
influxdb-sink : scala.MatchError: 93428746206 (of class java.math.BigDecimal) 1 2022-05-26 2022-09-27
server/mssql: support `update` mutations 1 2021-09-29 2022-09-14
Cannot see seek position on flyouts 4 2022-01-06 2022-08-30
Log output stuck when printing emoji to internalConsole with python 2 2022-05-12 2022-09-22
Lonhorn fails to install on Rancher 2.6 (Edge Doployment) 3 2021-12-27 2022-09-03
[Feature request] Recursive find of projects in a folder 4 2021-08-22 2022-09-27
cursor remains visible when evil-wants-minibuffer used 3 2020-01-04 2022-09-27
Update 4-codedeploy.md 0 2017-05-31 2022-01-15
Remove unnecessary await in `interactive`. 0 2021-10-15 2022-02-01
MSBuildProject needs to be testable 0 2022-02-03 2022-09-27