-
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
Can we pass objects these days with transitionTo ? #983
Comments
Not yet, but soon. |
Are we talking about passing information when changing state that we do not want to appear in the URL? Any way I can help? :) |
I have some code here that does just that if it helps. https://github.com/Webinfinity/ui-router/tree/optional-params |
@faxal its fixed in master but has not been released yet. It looks like they have it tagged for the |
+1 this feature would be awsome :-) |
@lightswitch05 got it thx ! |
Yes, this should be working now in 0.2.13.
|
Tried and worked using |
👍 |
Tried and worked with The target state seems to only reloaded if the param is different at a shallow level. Example in this plunker. In that example, I have an array that is filled with random numbers when you click the link. If I send that array into I would expect the state to be reloaded regardless, since the contents of the parameter changed. |
I'm pretty sure we don't do deep comparisons by default. I think we do 'a == b' and since you reuse the same array reference they are '=='. We have support for array-type for url parameters, but I'm not sure how that would work for non URL params ('array: true'). Otherwise, implement your own type with an equals() that deep compares. Come to think of it, you might be able to set the param type to "json" which does deep compare. |
I can't seem to find the param type 'json' in the documentation, is it a new addition? |
Your plunk works with 'json' type: http://plnkr.co/edit/kBmbxyaU8eWVlNKtEHwX?p=preview Yeah, json parameter type was added here: https://github.com/angular-ui/ui-router/releases/tag/0.2.13 but looks like it never got documented. Check it out: 027f1fc |
Indeed types 'json' and 'any' solve my issue on my production website, many thanks! Going over those commits, it seems the whole 'type' section of params is undocumented here. Would a PR of mine to document it be welcome, or is this something on the pipeline for later on? |
Hold up. I've made a few stupid mistakes while looking at your plunk:
So, now with a fresh perspective, the reason ui-router thinks your parameter has not changed in your original plunk is as follows:
The answer you're looking for is to create a copy of the array, before sending it to Note from above:
|
I think I understand. In fact, that My real world scenario is slightly more complex: I am live-updating several arrays, which then I put inside of an object and send it as parameters for |
Regarding your note, I believe this should do the trick:
I need to read up on the tests here on |
I don't think you want to rely on Can you instead do |
While developing a test, find the describe block you're interested in and change https://github.com/angular-ui/ui-router/blob/master/test/urlMatcherFactorySpec.js#L483-L591 |
I think you mean |
0.2.15 is still on an older jasmine version so it uses |
can we pass objects these days with transitionTo ?
The text was updated successfully, but these errors were encountered: