Read router params in the title property using string interpolation

This issue has been created since 2022-11-23.

Description

Is it possible to just read the params of the router with string interpolation without making a resolver or injecting the Title?

Proposed solution

{
    path: ':productId',
    component: ProductComponent,
    title: `Product details: ${:productId}`
  }

Alternatives considered

Or any other better solution?

atscott wrote this answer on 2022-11-24

No, but this is so trivial with functional resolvers that special handling for template strings is not necessary:

{
    path: ':productId',
    component: ProductComponent,
    title: (route) => `Product details: ${route.params['productId']}`
  }

stackblitz example: https://stackblitz.com/edit/angular-ivy-pz6chj?file=src%2Fmain.ts,src%2Findex.html

This was a easy to answer quickly but for the record, this doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests. In the future, please post your questions on StackOverflow using tag angular.

If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.

MonaGamal wrote this answer on 2022-11-24

@atscott Thank you for your reply and for the stackblitz sample.

That is exactly what we were looking for. It seems we have tried to make it in Angular 14 and it wasn't supported at that time as far as I understand.

Angular 14
title?: string | Type<Resolve<string>>;

Angular 15
title?: string | Type<Resolve<string>> | ResolveFn<string>;

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-12-01
Star Count 85220
Watcher Count 3042
Fork Count 22607
Issue Count 1316

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Markdown not displaying as expected 6 2018-12-19 2022-08-20
Tracking bundle/module sizes - file output (`.size-snapshot.json`) 5 2022-08-18 2022-11-13
添加文字的时候遇到的bug 1 2021-06-25 2022-01-22
Create a quickstart guide for the open source developer user 4 2021-06-07 2022-09-06
Create one or more quickstart guides for SRE/cloud operators/sysadmins 7 2021-06-07 2022-11-14
Strange Wi-Fi name showing up sometimes 1 2021-08-11 2022-11-25
Don't work with umi framework 1 2022-07-07 2022-09-15
[Bug] Fix Readme.md in the nuget packages 2 2021-11-15 2022-10-17
Suggestion - Hide Ghosted Plugins 1 2022-06-01 2022-11-02
Broken language change on latest 6.1.0 Beta 2 0 2021-08-17 2022-11-13
the ODrive board hardware can opensource? 2 2021-10-14 2022-11-22
Old mapping seem to be persistent 2 2021-11-18 2022-09-27
Chained `.tz()` calls not returning immutable object 2 2022-11-11 2022-11-23
unable to launch a forge instance 1 2021-12-22 2022-01-25
The "KILLED" value is missing from the QueryExecutionState enum 1 2021-05-06 2022-11-19
Hard to see text in the docs 1 2021-07-10 2022-09-25
How to set a relative URL? 2 2020-09-14 2022-11-22
Select 标签使用出问题 12 2018-06-16 2022-01-05
CI: Release-related minor issues 0 2021-01-26 2022-11-25
New Gitpod from sub directory of a (mono) repo 6 2021-11-10 2022-11-18
Missing is_* functions 1 2021-10-06 2022-11-30
JSON Import failes with "Timeout Expired" 1 2022-06-11 2022-11-11
Restore fails due to PD returns Unavailable not leader 2 2021-08-04 2022-11-22
Add approximately pattern 4 2020-04-29 2022-11-02
Support default values for configuration environment variables 4 2022-04-15 2022-10-31
resizeMode: "none" should imply native frame rates 5 2020-12-19 2022-09-10
liveReload bug? 1 2021-10-13 2022-01-22
Highway Pursuit 1.1 for Windows 3 2021-05-22 2022-11-18
Question: How to set CSS to Modal ? 2 2021-08-26 2022-10-25
Does JSHint support customized rules? 1 2021-11-26 2022-11-14
Dropdown Doesn't Seem to Work 4 2021-12-03 2022-10-10
修改完xml之后每次都要全量编译,非常耗时 4 2017-12-29 2022-11-07
PHP code coverage report generated with PHPUnit PHAR archive cannot be processed by phpcov 6 2021-01-05 2022-11-23
Different line coverage report result 1 2020-04-09 2022-11-23
[13] ¡Algo salió mal! × La cuota a compensar debe ser indicada como una cantidad positiva. 5 2021-06-17 2022-10-30
Warning: msg="Notify attempt failed, will retry later" attempts=1 err="'require_tls' is true (default) but \"localhost:25\" does not advertise the STARTTLS extension" 0 2021-09-01 2022-11-30
Compilation problem (rust-1.34.0, NetBSD) 3 2019-05-08 2022-11-28
cmd/go: add --as-needed and --no-as-needed to the linker flags whitelist 2 2018-02-08 2022-07-21
Trans(hierarchical-dependency-injection.jade) 1 2017-06-05 2022-11-27
Is Recoded Format more hardware-friendly for denormal numbers than IEEE754 format? 0 2020-10-27 2022-10-13
No guide on how to use recaptcha-module 4 2019-11-27 2022-11-09
[Bug]: DBeaver adds LIMIT 200 OFFSET 0 when querying a predictor - causes error 1 2022-05-31 2022-11-20
Error to join new Tikv PD node to the current Tikv PD cluster 4 2022-10-13 2022-11-30
Type predicate assertion does not carry over when used in another function 3 2022-10-27 2022-10-30
Design Meeting Notes, 10/21/2022 0 2022-10-27 2022-10-30
Design Meeting Notes, 10/26/2022 5 2022-10-27 2022-10-30
Update wasmparser requirement from 0.71 to 0.72 0 2021-01-15 2022-11-28
Better communicate failure to search-replace JSON-serialized URLs 9 2017-11-17 2022-11-25
Checkout: Error When Applying Coupon on Expired Domain 1 2022-01-11 2022-09-28
SOAP client is slow 4 2019-04-11 2021-11-26