-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Object set as readonly when passed as a route data #53632
Description
Which @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
I have a use case where I pass an environment const as a data for a specific route. And I just remark that after the migration to angular 17, this const is set to readonly when the user go to this route. But not when he go to the page with the url.
After some investigations this issue appear with the change of default value for paramsInheritanceStrategy (now set as emptyOnly by default). For me it's a bug since the behavior is not the same when paramsInheritanceStrategy: 'always'.
To do my test I just create 2 components with 2 different routes. One of this route use an environment const as data and the other route is here just to mock a navigation.
For the minimal reproduction :
Click on comp1
Click on test, an error should be throw in the console
Refresh the page when on the comp1
Click on test, nothing append
Click on comp2
Click on test, nothing append
Click on comp1
Click on test, an error should be throw in the console
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-jwxjng?file=src%2Fmain.ts
Please provide the exception or error you saw
TypeError: Cannot assign to read only property 'dumbValue' of object '[object Object]'
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 17.0.7
Node: 21.4.0 (Unsupported)
Package Manager: npm 10.2.5
OS: win32 x64
Angular: 17.0.7
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Anything else?
No response