【发布时间】:2014-12-15 17:44:41
【问题描述】:
我的 .cshtml 文件中有一个视图,其中有一个“更新”按钮 更新按钮有效,但我想重定向到主目录。
在我第一次拥有的 .js 文件中
success(function (data) {
//Showing Success message
alert("Incident Added");
$location.path("\Home");
})
链接从 /Home/Create 转到 /Home/Create#/Home 并停留在那里。我希望它回到我的主目录。基本上是在创建之后回到主视图。
我也试过了
success(function (data) {
//Showing Success message
alert("Incident Added");
$scope.$apply(function () {
$location.path("/Home");
});
})
并且该 url 之后没有添加 #/Home,但它与 /Home/Create 保持相同,并且没有转到 /Home。我想知道我需要做什么才能让它回家。或者更确切地说,学习如何正确地进行重定向。
【问题讨论】:
-
在您的
app.config中,您使用$routeProvider声明您根据用户输入的url 声明将用户发送到哪里。你的/home的templateUrl是什么?在这里你可以阅读更多关于$routeParamsdocs.angularjs.org/api/ngRoute/provider/$routeProvider
标签: angularjs html url redirect razor