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

ngRoute clashing route resolution #8266

Closed
@mchapman

Description

@mchapman

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions