Objects converted to ParamMap can err when ParamMap functions are called on them.
See original GitHub issue🐞 bug report
Affected Package
Error is in the Router module’s shared.ts file, on line 68. https://github.com/angular/angular/blob/79fb9d449c0fab9bdb5886f09d4fc9cd52f89318/packages/router/src/shared.ts#L68
Description
If an object is passed to the convertToParamMap
function is missing the hasOwnProperty
method. Attempts to call the new ParamsAsMap object’s has
, get
, or getAll
methods will all throw this error: TypeError: this.params.hasOwnProperty is not a function
.
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-igb464?embed=1&file=src/app/app.component.ts
🔥 Exception or Error
TypeError: this.params.hasOwnProperty is not a function
🌍 Your Environment
Angular Version:
Angular CLI: 6.0.8
Node: 10.1.0
OS: win32 x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 6.2.2
typescript 2.7.2
Anything else relevant?
I’m pretty sure this occurred because I created the initial Params
object using Object.create(null)
. At the time, I wanted a very plain object with no extraneous stuff on its prototype chain.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
How to unit test a Angular 4 component which uses router ...
paramMap should be of type ParamMap from @angular/router , so normal object can be converted to ParamMap using the method convertToParamMap() ...
Read more >ParamMap - Angular
A map that provides access to the required and optional parameters specific to a route. The map supports retrieving a single value with...
Read more >Compile Error: Illegal assignment from Object to String
You are assigning object to string variable. If it is necessary to assign then you can use String.valueof function.
Read more >about Functions Advanced Parameters - PowerShell
You can add parameters to the advanced functions that you write, and use parameter attributes and arguments to limit the parameter values ...
Read more >Subscribe to angular route parameter changes - YouTube
So modify the code in ngOnInit() method as shown below. // The paramMap property returns an Observable. So subscribe to it // if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jasonaden PR ready for a review
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.