feat(router): Add Route.title with a configurable TitleStrategy#43307
feat(router): Add Route.title with a configurable TitleStrategy#43307atscott wants to merge 4 commits intoangular:masterfrom
Route.title with a configurable TitleStrategy#43307Conversation
40248ad to
79d990a
Compare
a513187 to
4290baf
Compare
AndrewKushnir
left a comment
There was a problem hiding this comment.
@atscott looks great, just left some comments 👍
488c842 to
4718823
Compare
|
For public API reviewers, copying in the considerations for rolling this change out: Because we’re using the existing On the other hand, by not adding this as default behavior in the These two issues are both important to consider, but are generally at odds with each other. There are a couple options that we can explore here:
|
jessicajaniuk
left a comment
There was a problem hiding this comment.
LGTM 🍪
reviewed-for: public-api
|
You can preview 9ee31bd at https://pr43307-9ee31bd.ngbuilds.io/. |
petebacondarwin
left a comment
There was a problem hiding this comment.
Take a look at the AIO preview. I think the API docs need more content to explain how these classes are used (or at least a link to the guide). Also in the guide the example snippet given by the page-title region looks a bit strange since the constructor block has no context. I think it would be better to include the class in the snippet too.
The override modifier on the setTitle() method appears to have exposed a bug in our doc-gen: https://pr43307-4718823.ngbuilds.io/api/router/BrowserPageTitleStrategy#override.
For some reason the override is being treated as a property in its own right!!
I'll look into this.
ccbaaf4 to
2b263a2
Compare
|
You can preview 2b263a2 at https://pr43307-2b263a2.ngbuilds.io/. |
2b263a2 to
70f9756
Compare
|
You can preview 70f9756 at https://pr43307-70f9756.ngbuilds.io/. |
9850189 to
0f4198b
Compare
d42de88 to
2c41125
Compare
Route.title with a configurable TitleStrategy
AndrewKushnir
left a comment
There was a problem hiding this comment.
Looks great, thanks for your work on this feature 👍
There was a problem hiding this comment.
Since this is a public API, it might be confusing to have both titleStrategy and defaultTitleStrategy as arguments. Would it be possible to have an intermediate factory function in the RouterTestingModule providers that would select custom or default strategy and pass only one to this function?
I had similar question for the setupRouter function, but it's not public, so this is not a concern there.
dylhunn
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
This commit provides a service, `PageTitleStrategy` for setting the document page title after a successful router navigation. Users can provide custom strategies by extending `TitleStrategy` and adding a provider which overrides it. The strategy takes advantage of the pre-existing `data` and `resolve` concepts in the Router implementation: We can copy the `Route.title` into `data`/`resolve` in a non-breaking way by using a `symbol` as the key. This ensures that we do not have any collisions with pre-existing property names. By using `data` and `resolve`, we do not have to add anything more to the router navigation pipeline to support this feature. resolves angular#7630
2a869c1 to
df64339
Compare
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api, size-tracking
|
This PR was merged into the repository by commit 910de8b. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…ngular#43307) This commit provides a service, `PageTitleStrategy` for setting the document page title after a successful router navigation. Users can provide custom strategies by extending `TitleStrategy` and adding a provider which overrides it. The strategy takes advantage of the pre-existing `data` and `resolve` concepts in the Router implementation: We can copy the `Route.title` into `data`/`resolve` in a non-breaking way by using a `symbol` as the key. This ensures that we do not have any collisions with pre-existing property names. By using `data` and `resolve`, we do not have to add anything more to the router navigation pipeline to support this feature. resolves angular#7630 PR Close angular#43307
This commit provides a service,
PageTitleStrategyfor settingthe document page title after a successful router navigation.
Users can provide custom strategies by extending
TitleStrategyandadding a provider which overrides it.
The strategy takes advantage of the pre-existing
dataandresolveconceptsin the Router implementation:
We can copy the
Route.titleintodata/resolvein anon-breaking way by using a
symbolas the key. This ensures that wedo not have any collisions with pre-existing property names. By using
dataandresolve, we do not have to add anything more tothe router navigation pipeline to support this feature.
resolves #7630
reviewer notes: thoughts/design doc