0

I've got routing that looks like this:

.when "/:locale",
  templateUrl: "/views/index.html"
...
.otherwise redirectTo: "/en"

The issue is that the first route also matches /. Is there a way to add required route segments, so that /:locale would only match if there's actually non-empty string?

I could probably listen to $routeChangeStart and implement otherwise condition there, but it would be much easier if I could do it all in a single place.

szimek
  • 6,404
  • 5
  • 32
  • 36
  • see answer here: http://stackoverflow.com/questions/14216565/how-to-have-wildcards-in-angular-routes – Maxim Shoustin Oct 01 '13 at 08:02
  • Thanks, but it doesn't really answer my question. I'm not asking about wildcards, but single route segment that's not optional. I don't have any controller for that action, as it's only rendering a template and doesn't have any logic. – szimek Oct 01 '13 at 08:25
  • It looks like it was broken recently in 1.2.0 RC2: https://github.com/angular/angular.js/commit/04cebcc133c8b433a3ac5f72ed19f3631778142b#commitcomment-3866914 – szimek Oct 01 '13 at 08:32

2 Answers2

0

Looks like it was broken in 1.2.0 RC2 by this commit and there's already a pull request to fix it that will land in 1.2.0 RC3.

szimek
  • 6,404
  • 5
  • 32
  • 36
0

Try this , sorry i can not understand your need , but i hope this will work

.when "",
  templateUrl: "/page.html"
.when "/",
  templateUrl: "/page.html"
.when "/:locale",
  templateUrl: "/views/index.html"
...
.otherwise redirectTo: "/"
Nishchit
  • 18,284
  • 12
  • 54
  • 81