Skip to content

$stateParam parsing behaviour changed in 0.2.12 #1537

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
mkulke opened this issue Nov 14, 2014 · 3 comments
Closed

$stateParam parsing behaviour changed in 0.2.12 #1537

mkulke opened this issue Nov 14, 2014 · 3 comments

Comments

@mkulke
Copy link

mkulke commented Nov 14, 2014

Hello there,

In 0.2.11 the url params test/:id were parsed to numbers in some cases (it did for ui-sref, but not for href or direct links). in 0.2.12 this behaviour changed to being parsed always to string. Is this by purpose?

0.2.12 plnkr
0.2.11 plnkr

Our tests are written like described in the wiki (https://github.com/angular-ui/ui-router/wiki/URL-Routing#stateparams-service):

$stateProvider
    .state('contacts.detail', {
        url: "/contacts/:contactId",
        templateUrl: 'contacts.detail.html',
        controller: function ($stateParams) {
            // If we got here from a url of /contacts/42
            expect($stateParams).toBe({contactId: 42});
        }
    })

and fail w/ 0.2.12 then.

@christopherthielen
Copy link
Contributor

Hi, you're seeing

default to parameter string coersion. (13a468a, closes #1414)

https://github.com/angular-ui/ui-router/blob/master/CHANGELOG.md

If you want int parameters, now you can declare it and always get ints (not sometimes-ints-sometimes-strings)

$stateProvider
    .state('contacts.detail', {
        url: "/contacts/{contactId:int}",
        templateUrl: 'contacts.detail.html',
        controller: function ($stateParams) {
            // If we got here from a url of /contacts/42
            expect($stateParams).toBe({contactId: 42});
        }
    })

Please close if this answers your question.

@mkulke
Copy link
Author

mkulke commented Nov 14, 2014

Yes. thanks for the quick clarification, i updated the wiki accordingly, i hope that's fine.

@mkulke mkulke closed this as completed Nov 14, 2014
@christopherthielen
Copy link
Contributor

i hope that's fine.

yes, thanks!

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

2 participants