[英]Redirect in AngularJs
I have the following code 我有以下代码
$scope.insertTodo = function(){
TodoService.post($scope.todo);
$location.path("/#/");
}
It should run TodoService.post() (and he does fine) and after that redirect the user to /#/
location. 它应该运行TodoService.post()(他做得很好),然后将用户重定向到
/#/
位置。 The redirect is not working. 重定向不起作用。 What am i doing wrong ?
我究竟做错了什么 ?
Thank you. 谢谢。
You need to change $window.location.href like this 您需要像这样更改$ window.location.href
var app = angular.module('RedirectApp', []);
app.controller('RedirectURLCtrl', function($scope, $window) {
$scope.RedirectToURL = function() {
var host = $window.location.host;
$window.location.href = "http://" + host + "/#/";
};
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.