Comments (36)
You just showed me the issue :D. The value of the param is null which is not an object :D
from ui-router.
Well, I think your case is still supported so I'll add a fix for your case!
from ui-router.
The loop in stateParams.js kept adding the word 'chunk' in parentParamsKeys.
(node_modules/@uirouter/core/lib-esm/params/stateParams.js)
I don't know what causes that, but I changed the loop from
for (let j in parentParamsKeys) {
if (parentParams[parentParamsKeys[j]].inherit == false || inheritList.indexOf(parentParamsKeys[j]) >= 0)
continue;
inheritList.push(parentParamsKeys[j]);
inherited[parentParamsKeys[j]] = this[parentParamsKeys[j]];
}
to
parentParamsKeys.forEach(j => {
if (parentParams[j].inherit == false || inheritList.indexOf(j) >= 0)
return;
inheritList.push(parentParamsKeys[j]);
inherited[parentParamsKeys[j]] = this[parentParamsKeys[j]];
});
now it works.
from ui-router.
@ckLocal is this not what you need? https://www.npmjs.com/package/@uirouter/angularjs/v/1.1.0
from ui-router.
@EoinGriffin-AI You shouldn't make custom methods into prototype enumerable. Can you show me the code that adds those methods?
Ah you're right, thanks for pointing out that they're non-standard functions. It's some old custom code added many years ago to our codebase. I can change their definitions to not be enumerable.
from ui-router.
Make sure that you manually specify @uirouter/core in your package.json
from ui-router.
Hello, thanx for the answer. I did it, i added "@uirouter/core": "^6.1.0" dep into package.json but still have the same error. Do i need to inject it into the angularjs scope?
from ui-router.
Are you using any other packages from uirouter?
from ui-router.
Ah sorry, didn't catch! No, no other package, only angularjs and core.
from ui-router.
Which version did you update from?
from ui-router.
1.0.30 and it works perfectly!
from ui-router.
I can't see anything that'd make it break. Can you try uirouter/core 6.0.8?
from ui-router.
Just tested using core 6.0.8 and that fixed the problem, works like a charm!
from ui-router.
6.0.9 breaks as for 6.1.0
from ui-router.
I think I found out what the problem is. Do you have params declarations as strings instead of objects?
from ui-router.
Uhmmm, params in state are always declared as objects like this:
$stateProvider
.state('myStateName', {
url: '/myPage',
params: {
a: null,
b: null
}
});
I've looked into all the project and unfortunately i didn't find any param defined as string, only objects.
from ui-router.
Ok, i'm going to cleanup my code! Thank you!!!!
from ui-router.
@p3pp8 I'm having some issues reproducing the issue in the unit tests. Would you be able to send me a basic state declaration structure that makes this fail? So that I can test my fix.
from ui-router.
Hello @wawyed, the example in the post above is extracted from my project (with some renaming) and is a basic state declaration with default params set to null. I think they should've been declared like this:
$stateProvider
.state('myStateName', {
url: '/myPage',
params: {
a: { value: null },
b: { value: null }
}
});
Thank you for the support!
from ui-router.
If you change it as above the error disappears?
from ui-router.
We have unit tests that test such functionality but they pass
from ui-router.
I'm going to try!
from ui-router.
Nothing to do, i've changed all params to have { value: null } instead of null but the error is still there...
from ui-router.
Okay... so it's not that.. would you be able to put a breakpoint where it errors and see which param is trying to access?
from ui-router.
The project is very complex and loads many angular components with states, i'll try to do my best but it's not as simple as put a breakpoint
from ui-router.
I think i have to wait for a new release, but that's not a problem. Thank you guys!
from ui-router.
@christ182 can you inspect parentParamsKeys, check Object.keys(parentParamsKeys) wondering if for some reason there's some enumerable properties added to that array?
from ui-router.
@wawyed Object.keys is working as expected. It's the loop that does not behave properly.
from ui-router.
I found the reason for mine.
Array.prototype.chunk = function(n) {
if (!this.length) {
return [];
}
return [this.slice(0, n)].concat(
this.slice(n).chunk(n)
);
}
for(var i in parents)
must include functions as keys.
Although, I have this Array.prototype.chunk code in for some time now. I don't understand how it suddenly broke.
from ui-router.
The reason I said Object.keys() it's because it retrieves the enumerable properties of the array. I wasn't referring to the existing Object.keys.
Regardless I think I have a fix based on your latest comment.
from ui-router.
I do suggest though that you use Object.defineProperty() instead and make chunk non enumerable to avoid further issues.
from ui-router.
@wawyed Can V1.1.0 be released as soon as possible?
from ui-router.
@wawyed Yeah, this is what I want, that's great.
from ui-router.
Hi, I'm running into this same error and I don't see a similarity to @p3pp8's configuration.
Note the value of j
is 'clear'
here. Seems like that's referencing the clear prototype method of the parentParamsKeys array... but why?
Here's where my states are defined. Is there an incompatibility here? I'm upgrading from angular-ui-router 0.4.2 to @uirouter/angularjs 1.1.0 (yes, this is a legacy app that I must support)
(function () {
'use strict';
var theModule = angular.module('ai.fieldData', [
'ui.router'
// Various other imports removed, for reading clarity.
]);
theModule.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: '',
templateUrl: 'source/application/application.html',
controller: 'FieldDataController',
})
.state('app.formContainer', {
abstract: true,
url: '/locations/:locationId/visits',
templateUrl: 'source/application/form-container.html',
controller: 'FormController',
});
$urlRouterProvider.otherwise('');
});
}());
from ui-router.
Indeed that 'clear'
is an array prototype method... how could I have possibly misconfigured my states to make this happen?
Here's what the loop should look like. Someone forgot to add the hasOwnProperty() check, to omit prototype properties and functions.
for (var j in parentParamsKeys) {
if (!parentParamsKeys.hasOwnProperty(j) || parentParams[parentParamsKeys[j]].inherit == false || inheritList.indexOf(parentParamsKeys[j]) >= 0)
continue;
inheritList.push(parentParamsKeys[j]);
inherited[parentParamsKeys[j]] = this[parentParamsKeys[j]];
}
from ui-router.
@EoinGriffin-AI You shouldn't make custom methods into prototype enumerable. Can you show me the code that adds those methods?
from ui-router.
Related Issues (20)
- Resolve triggering twice HOT 1
- No services listed in 2.x docs HOT 2
- Optional params included on all similar routes HOT 1
- child states of lazy loaded future states get stuck in stateQueue HOT 1
- Transition Rejection : while upgrading angularjs from 1.5 to 1.8 using angular-route:1.0.0 HOT 1
- this.parent.parameters() is not a function while Upgrading angular-ui-router from 0.2.15 to 1.0.29
- I used transition.onStart() instead of stateChangeStart, but it shows .onStart is not a function.
- Documentation Broken HOT 1
- Access states' custom data-object in component
- dependency's version is not the same
- Update @uirouter/core dependency to 6.0.9 HOT 3
- Support for Standalone components HOT 1
- Is this library still being maintained? HOT 1
- AngularJS v1.3.5 - Page reloads on route change after npm install for latest build.
- Angular: StateService injected in custom library results in R3InjectorError
- ui-router
- https://github.com/angular-ui/ui-router/tree/e8694114594d5aaf9f40e27b8ba194bca85595de
- str.split is nto a function HOT 1
- Please release the 1.1.0 version as soon as possible. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ui-router.