Skip to content

$state.go('/list', {aParam: null}) throws TypeError: Cannot read property 'toString' of null. #3197

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

Closed
vovopap opened this issue Dec 11, 2016 · 4 comments
Milestone

Comments

@vovopap
Copy link

vovopap commented Dec 11, 2016

angular -v : 1.5.8
ui-router -v: 0.3.2

$stateProvider.state({
url: '/list?{aParam:int}',
......
});
$state.go('/list', {aParam: 13}) works
$state.go('/list', {aParam: undefined}) works
$state.go('/list', {aParam: null}) throws error

Is this expected behavior? If it is, could you direct me to docs or guides. If it is not, i would like to provide a plunker.

@christopherthielen
Copy link
Contributor

christopherthielen commented Dec 15, 2016

If anything, I would expect that to throw an error about the param value being invalid.

That's a bug, thanks for reporting it!

Here's the problem:

    "int": {
      encode: valToString,
      decode: function(val) { return parseInt(val, 10); },
      is: function(val) { return isDefined(val) && this.decode(val.toString()) === val; },
      pattern: /\d+/
    },

We should check if val !== null in the is() function

@christopherthielen
Copy link
Contributor

This is also a bug in 1.0, so tagging appropriately. After the fix goes into 1.0 it should be backported to legacy for the 0.4.0 release.

@christopherthielen christopherthielen added this to the 1.0.0-beta.4 milestone Dec 15, 2016
@christopherthielen
Copy link
Contributor

christopherthielen commented Jan 3, 2017

Closed by ui-router/core@aa551e4 in 1.0

@christopherthielen christopherthielen modified the milestones: 0.3.3, 1.0.0-beta.4 Jan 3, 2017
christopherthielen added a commit that referenced this issue Jan 3, 2017
Fixes message: Cannot read property 'toString' of null
Closes #3197
@christopherthielen
Copy link
Contributor

Fixed by 61728d7 in 0.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants