Skip to content
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

$stateParams array value is converted to string when single element #2979

Closed
crystalneth opened this issue Sep 7, 2016 · 4 comments
Closed

Comments

@crystalneth
Copy link

When calling $state.go('app.foo', {someArray: ['a']}), the $stateParams.someArray is received as 'a'. When there are multiple values, it is received correctly as an array. This makes consistent processing difficult.

@crystalneth crystalneth changed the title $stateParams with array is converted to string when single element $stateParams array value is converted to string when single element Sep 7, 2016
@christopherthielen
Copy link
Contributor

Is it in a query parameter? If so, force the 'array mode' to true: params: { someArray: { array: true } }

https://ui-router.github.io/docs/latest/interfaces/params.paramdeclaration.html#array

Can you show me the app.foo definition?

@christopherthielen
Copy link
Contributor

Closing due to no activity

@malltshik
Copy link

It's well work for me. But if use [] in place new Array() array can be cast to a string

url: 'posts?s&tags&page',
params: { s: null, tags: new Array(), page: null },
templateUrl: "/static/templates/posts/posts.html",

@parallaxisjones
Copy link

parallaxisjones commented Sep 6, 2017

I'm seeing the same behavior, works with more than one array member, but an Array of length 1 or less isn't an array, but a single value. Using the alternate syntax ?kind[]=example would work here

export const index = { name: RESOURCE_INDEX, url: '/search?kind', data: { authenticate: true }, params: { kind: { array: true }, view: null }, component: Search }

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

No branches or pull requests

4 participants