core icon indicating copy to clipboard operation
core copied to clipboard

Issue with StateParams

Open p3pp8 opened this issue 1 year ago • 3 comments

uirouter/core v6.1.0. I'm facing this issue:

modules.js?hash=5f47…9fe47f2ba01d:280243 TypeError: Cannot read properties of undefined (reading 'inherit')
    at StateParams.$inherit (modules.js?hash=5f47…47f2ba01d:309683:55)
    at StateService.href (modules.js?hash=5f47…47f2ba01d:311445:34)
    at BaseUrlRule.handler (modules.js?hash=5f47…47f2ba01d:313502:24)
    at UrlService.sync (modules.js?hash=5f47…47f2ba01d:313756:39)
    at modules.js?hash=5f47…7f2ba01d:313788:104
    at modules.js?hash=5f47…7f2ba01d:304237:125
    at Array.forEach (<anonymous>)
    at modules.js?hash=5f47…47f2ba01d:304237:94
    at Scope.$broadcast (modules.js?hash=5f47…47f2ba01d:284396:28)
    at afterLocationChange (modules.js?hash=5f47…47f2ba01d:280073:18)

Thanx for your help, really appreciated!

p3pp8 avatar Mar 19 '24 10:03 p3pp8

I am seeing the same thing in the StateParams.prototype.$inherit() function.

As the image below shows, the for on line 24 has iterated past a valid "#" parameters and then carries on to a key named "objectPresent", which is a property of the prototype. This return undefined and then the error when attempting to get the "inherit" property. image

I'm trying to upgrade my hybrid application to Angular 16. Could this possibly be a version incmpatibility? This is what I have: "@uirouter/angular": "^12.0.0", "@uirouter/angular-hybrid": "^16.0.0", "@uirouter/angularjs": "^1.1.0", "@uirouter/core": "^6.1.0", "@uirouter/rx": "^1.0.0", "@uirouter/visualizer": "^7.2.1", "angular-ui-router": "^1.0.29", "angular": "~1.5.0",

Any help/advice gratefully received

Thanks

bobgear-eic avatar May 30 '24 07:05 bobgear-eic

I believe this is the same as https://github.com/angular-ui/ui-router/issues/3851 . You probably have custom prototype methods on the array that for some reason have been defined as enumerable. You should use Object.defineProperty (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty) instead

wawyed avatar May 30 '24 08:05 wawyed

@wawyed Thank you! It's some pretty old code that I'm returning to and I never dreamed that I'd done this to the prototype! I've been puzzling over this for hours and I had no recollection of it being right there in my own code - so thanks very much for the tip!

bobgear-eic avatar May 30 '24 11:05 bobgear-eic

This should be now fixed in 6.1.1

wawyed avatar Jul 16 '24 16:07 wawyed