0

我的路由看起来像这样:

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

问题是第一条路线也匹配/。有没有办法添加所需的路线段,这样/:locale只有在实际上有非空字符串时才会匹配?

我可能可以在那里听$routeChangeStart并实施otherwise条件,但如果我能在一个地方完成所有操作会容易得多。

4

2 回答 2

0

看起来它在 1.2.0 RC2 中被 这个提交破坏了,并且已经有一个修复它的请求请求将在 1.2.0 RC3 中登陆。

于 2013-10-01T08:39:40.367 回答
0

试试这个,对不起,我不能理解你的需要,但我希望这会奏效

.when "",
  templateUrl: "/page.html"
.when "/",
  templateUrl: "/page.html"
.when "/:locale",
  templateUrl: "/views/index.html"
...
.otherwise redirectTo: "/"
于 2013-10-09T04:58:45.303 回答