-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ParamMap returns a number if number used in navigate #23165
Comments
At the start they both are of type Object (Output shows) ngOnInit() {
} output:- Conclusion :- Solution :- |
I can't tell what you're trying to say
EDIT: I have decoded it I think. The issue is that if you put a number into the url using router navigate, it will be of type "number", which breaks the promise of the API that param.get() will return a string. So your solution is right, the implementation should toString the router input.
What is confusing is that after a refresh (you can test in example) the value becomes a string again, naturally
…On Tue, 17 Apr 2018, 01:52 kambleaa007, ***@***.***> wrote:
At the start they both are of type Object (Output shows)
As you declared them as Any (Line no. 13,14)
There is nothing like String as per your question
Its fine I checked with output not test cases :-
ngOnInit() {
setInterval(() => {
this.router.navigate([{
numVal: Math.floor(Math.random()*20).toString(),
strVal: Math.floor(Math.random()*20).toString()}
], {relativeTo: this.route});
}, 3000);
this.route.paramMap.subscribe((paramMap: ParamMap) => {
this.numVal = paramMap.get('numVal');
this.strVal = paramMap.get('strVal');
this.numValType = typeof this.numVal;
this.strValType = typeof this.strVal;
});
}
output:-
numVal: 11 string strVal: 16 string
numVal: 16 string strVal: 11 string
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#23165 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB8rgNc1W4B6RaeO1m6a2bB0DLD_Votwks5tpS6ygaJpZM4THEYl>
.
|
Fix a case where matrix parameters weren't stringified when they are passed as a first command when creating a url tree. Fix return type in parseMatrixParams method because it always returns {[key: string]: string} Closes angular#23165
Fix a case where matrix parameters weren't stringified when they are passed as a first command when creating a url tree. Fix return type in parseMatrixParams method because it always returns {[key: string]: string} Closes angular#23165
Fix a case where matrix parameters weren't stringified when they are passed as a first command when creating a url tree. Fix return type in parseMatrixParams method because it always returns {[key: string]: string} Closes angular#23165
I just experienced this issue, too. And it's getting even worse with objects:
|
It seems like this is not only limited to I would definitely prefer #25095 since this solves the root issue with |
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. |
I'm submitting a...
Current behavior
Optional route params that are given as numbers in navigate remain as numbers until page is refreshed.
Expected behavior
Would expect this to always be a string, as paramMap.get() claims
Minimal reproduction of the problem with instructions
https://angular-gitter-gd3f8s.stackblitz.io/notTheRoot;numVal=9;strVal=14
https://stackblitz.com/edit/angular-gitter-gd3f8s
The values change every 3 seconds. On page load, numVal will be a string, but then after updating will be a number. strVal is the same, except toString is called.
What is the motivation / use case for changing the behavior?
Actual types matching types declared by api
Environment
See StackBlitz
The text was updated successfully, but these errors were encountered: