2017-01-22 124 views
-1

请帮我设置路由角度...设置角度的路由

当没有$ location.path()index.html和MainController必须加载。 当$ location.path()= @ *时,其中*任何对象的名称都必须加载index2.html和myController。

现在它不工作:

app.config(function ($routeProvider) { 
    $routeProvider 
     .when("/", { 
      templateUrl: "index.html", 
      controller: "MainController" 
     }) 
     .when("/@*", { 
      templateUrl: "index2.html", 
      controller: "myController" 
     }); 
}); 

回答

0

如果他们是你的只有两条路,你可以使用otherwise(params):将在航线 变化时,可以使用

集路由定义没有其他路由定义匹配。

app.config(function ($routeProvider) { 
    $routeProvider 
     .when("/", { 
      templateUrl: "index.html", 
      controller: "MainController" 
     }) 
     .otherwise({ 
      templateUrl: "index2.html", 
      controller: "myController" 
     }); 
}); 
+0

当我试图直接打开'url.com/@ object' ...有 “不能GET/@对象”,我究竟做错了什么? – Daryushka

+0

正确我看,问题是你不是URL编码的字符串。你不能在URL中使用'@'。如果需要的话,你必须按照[这里](http://www.w3schools.com/tags/ref_urlencode.asp)的解释将它编码为“%40” –