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

path/ not matching path/:something now in 0.2.17 #2490

Closed
shadybones opened this issue Jan 26, 2016 · 4 comments
Closed

path/ not matching path/:something now in 0.2.17 #2490

shadybones opened this issue Jan 26, 2016 · 4 comments
Milestone

Comments

@shadybones
Copy link

code:
$urlRouterProvider.when('/project/:id','/project/:id/summary');

0.2.15 : matched "project/" and "project/1" ( "project/" forwarded to "project//summary")
0.2.17 : matches "project/1" only ( "project/" stays where it is)

Is this the new expected behavior or a bug?

@eddiemonge
Copy link
Contributor

I feel like this is a bug correction but it could also be a breaking change. @nateabele

@christopherthielen
Copy link
Contributor

http://bit.ly/UIR-Plunk

@christopherthielen
Copy link
Contributor

can you try moving the $urlRouterProvider.when('/project/:id','/project/:id/summary'); to the top of your config block? That is, move it above all calls to $stateProvider.state().

Are you trying to do a "default substate" of the project state? There's a more state-machine way to do that:

If a transition is headed for 'project', cancel it and go to 'project.summary' instead.

$rootScope.$on("$stateChangeStart", function(evt, toState, toParams) {
  if (toState.name === 'project') {
    evt.preventDefault();
    $state.go('project.summary', toParams);
  }
}

That chunk of code can be generalized to:

$rootScope.$on("$stateChangeStart", function(evt, toState, toParams) {
  if (toState.redirectTo != null) {
    evt.preventDefault();
    $state.go(toState.redirectTo, toParams);
  }
}

...
$stateProvider.state('project', {
  url: '/project/:id',
  // declare a default substate, which the $stateChangeStart listener will notice
  redirectTo: 'project.summary'
  template: ...
  controller: ...
});

@christopherthielen christopherthielen added this to the 0.2.18 milestone Feb 7, 2016
@christopherthielen
Copy link
Contributor

Still waiting on a plunker, but I think this was related to #2501

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

No branches or pull requests

3 participants