【发布时间】:2016-11-18 21:04:07
【问题描述】:
我有一个角度应用程序,我在应用程序中使用部分视图并使用 $routeProvider 进行路由,该应用程序托管在服务器中,一切正常。
启动应用的 URL 类似于http://servername/?instanceId=862gh2g2323238
请注意,启动应用程序需要实例 ID,应用程序的主页包含食谱列表
这里是如何设置路由的示例代码
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "views/view_index.html",
controller : "mainCtrl"
})
.when("/recipe/:index", {
templateUrl : "views/view_recipe.html",
controller : "recipeCtrl"
});
在我的 view_index.html 我有
<a ng-href= "#recipe/{{index}}" >...
调用配方的相应视图
当我单击任何配方进入详细信息页面时,在浏览器中发出它,浏览器 url 更改为
URL://servername/?instanceId=862gh2g2323238#/recipe/0
我希望它会像
http://servername/#/recipe/0?instanceId=862gh2g2323238
请告诉我,我可能缺少什么??
【问题讨论】:
标签: javascript angularjs angular-routing route-provider