$rootScope.path('/') 不起作用



我有一个如下所示的 register(( 函数。

<form class="form-auth" ng-submit="register()">

我定义如下

$scope.register = function(){
$http.post('/auth/signup', $scope.user).success(function(data){
  $rootScope.authenticated = true;
  $rootScope.current_user = data.user.username;
  $rootScope.path('!/');
});

};

问题是最后一行:

$rootScope.path('!/');

它不会把我带到我引导它的路径。 我已经尝试了几种变体,('/'(和(#!/(,但似乎没有一种有效。

您需要

使用$location服务,而不是$rootScope。

$location.path('/');

最新更新