question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
abarghoudcommented, Jul 17, 2019

@jasonaden PR ready for a review

0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found