Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngRoute clashing route resolution #8266

Closed
mchapman opened this issue Jul 19, 2014 · 2 comments
Closed

ngRoute clashing route resolution #8266

mchapman opened this issue Jul 19, 2014 · 2 comments

Comments

@mchapman
Copy link
Contributor

I have an issue where modules are being loaded after the module I have control of that are adding clashing routes.

So something along the lines of:

myModule.config($routeProvider) {
  $routeProvider.when(':model',{templateUrl: 'partials/showItemsInModel.htm'})
}

theirModule.config($routeProvider) {
  $routeProvider.when('dashboard',{templateUrl: 'partials/dashboard.htm'})
}

Obviously I can change my route (and am doing so for the time being), but I wondered if something else could be done, and thought of three possibilities:

  • Add an optional sort order causing .when to insert into the route array at the appropriate place
  • Have a .else (or .elsewhen) which has an implicit sort order between .when and .otherwise
  • Once the route has been matched carry on matching looking for a 'better' match (a regex with less variables). I think it may be possible to automatically insert general routes below less general routes that they would match (but I haven't worked on it).

I could work on a PR if this was deemed to be worthwhile and there was some guidance about which option (if any) was preferred.

@Narretz Narretz added this to the Backlog milestone Jul 21, 2014
@Narretz
Copy link
Contributor

Narretz commented Jul 21, 2014

That is a pretty interesting case, because usually third party modules don't add routes to an app, but rather components (directives, services). I think it's a pretty rare occurence and might live in a third-party module that is ngRoute compatible but is extended to handle this case (You can of course open a PR and present it for review.). I'd prefer the third case which orders the routes automatically from explicit to less explicit.

@Narretz
Copy link
Contributor

Narretz commented Mar 19, 2018

This is out of scope at this point of AngularJS development. uiRouter has better support for clashing routes and should be used if this is needed.

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

No branches or pull requests

3 participants