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

ui-router route controller executes twice when using array of query parameters #1511

Closed
jrzerr opened this issue Nov 4, 2014 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@jrzerr
Copy link

jrzerr commented Nov 4, 2014

I am using an array of query parameters and finding that my route controller executes twice. So /route/1?test=2 executes route controller once as expected, but /route/1?test=2&test=3 executes the route controller twice.

Plunker to reproduce the bug

In short:

A route configured like:

$stateProvider
  .state('route', {
      url: "/route/:routeid?test",
      templateUrl: "route.html",
      controller: function($scope,$stateParams){
          console.log('route ctrl',$stateParams)
      }
  })
});

From my main controller, when I do a $state.go('route', {routeid: "1", test: ""}); or $state.go('route', {routeid: "1", test: "2"}); the route controller executes once.

When I use an array parameter, like $state.go('route', {routeid: "1", test: ["2", "3"]}); the route controller executes twice.

Is this the expected functionality, or is it a bug? If it is expected, I'd like to understand why.

@christopherthielen
Copy link
Contributor

@jrzerr I appreciate the detailed bug report, thank you!

@christopherthielen
Copy link
Contributor

Related #1538

http://plnkr.co/edit/b7HfFk?p=preview

Your bug highlights some additional corner cases that were not addressed in the fix for #1538. I've addressed those cases now and this will be fixed in 0.2.13. See the test cases I added in https://github.com/angular-ui/ui-router/blob/master/test/urlMatcherFactorySpec.js#L211 for the expected behavior with "auto" array boxing.

@jrzerr
Copy link
Author

jrzerr commented Nov 17, 2014

@christopherthielen Really appreciate you going the extra mile and adding those test cases in.

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

No branches or pull requests

2 participants