feat: accept UrlTree in navigate and initialRoute - #603
gabrielmethot wants to merge 1 commit into
Conversation
timdeschryver
left a comment
There was a problem hiding this comment.
Thanks for addressing this, @gabrielmethot.
Do you think this should also be added to the zoneless API (public_api.ts)?
I鈥檓 asking because I鈥檇 like to keep it as minimal as possible. Since this is essentially just router.navigate([path]), I鈥檓 not sure it鈥檚 needed there. AFAIK, most component tests aren鈥檛 concerned with routing logic itself.
You can ignore the failed build, I will look into it.
Thanks for the feedback! I wasn't aware of the ongoing work to define a smaller API and lean more on Angular's own testing utilities.
As for this PR, I would understand not wanting to grow the API surface of something that's headed for deprecation, so I'll leave it up to you whether to merge it. If you do, I agree it doesn't need to go into the zoneless API. |
Hello,
This pull request adds new signatures to
navigateandinitialRouteto allow passing instances of UrlTree. This makes query params easier to configure because Angular handles the serialization. It also lets us pass a route fragment, which wasn't supported with string paths.String paths work the same as before, but they behave differently from a
UrlTreebecause they go through the library's own parser, which doesn't decode values or handle fragments. This can be surprising, so I documented it in the JSDoc.It might be worth considering using Angular's parser as the default, because that's probably what most developers expect. The custom query params parser could then be deprecated. Since this would be a breaking change, it might fit better in a future major version. I'd love to hear your thoughts about this.
Thanks for taking the time to review this, and for your work on the library!