-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Problem with default value of null for a param #1563
Comments
I also faced a similar problem. 'null' value for state-params works fine till v0.2.11 but gives an error in v0.2.12. |
I had that same problem. Handling was changed in 0.2.11 from null to undefined but it worked fine until 0.2.12 version. Its no longer default to null but undefined as noted in CHANGELOG BREAKING CHANGE: state parameters are no longer automatically coerced to strings, and unspecified parameter values are now set to undefined rather than null. so undefined should work, hope it helps, I had a problem with it in ui-sref and removing those null parameters work fine as it should from 0.2.11 release |
One negative effect of this issue with ui-sref/ui-sref-active:
Up to 0.2.12, this code would work as expected. Either All or Red is active.
Since version 0.2.12, you have to write the code in one of the following form, which all behave in a wrong way (either all is always active or never active). omitting the key
using undefined as the key value
or using an empty string
|
I'd like to make sure this is addressed before I release 0.2.13 (which should be real soon now). Can you put this into a plunk for me? And/or build from master and check it works properly already. |
http://plnkr.co/edit/awhez1GjpDrt11uQqeif I discovered in the process that the angular version matter. The plunk above use Angular@1.2.25 and ui-router@0.2.12.
|
http://plnkr.co/edit/OmVLsTIms86ka7hPXIeK Navigate to /#/one/two?startDate=2014-11-17 |
@christopherthielen added another test case, showing a default value of an empty string. I believe this is actually the issue reported in #1564 |
I ran into a similar problem when I was trying to clear out a parameter by setting it to null in the params arg of
In the above line,
The problem is the filter impl:
It should be more like:
I think this will fix the default param issue as well. |
@samiconductor thanks |
This worked for me thanks |
I'm seeing an error generated in urlMatcherFactory.js by the code that sets a default value.
This occurs when you have an optional param and a default value of null.
The problem occurs in the hasReplaceVal closure, when obj is null/undefined, obj.from causes the error. 'value' is checked if it is defined until after the call to $replace.
I was using this state config:
I also tried using the string type instead of the date type and the same result occurred.
Changing the default value to an empty string instead of null, allowed it to work, as obj.to would then return undefined instead of causing an error.
The text was updated successfully, but these errors were encountered: