我如何使用$ location.state()

时间:2017-05-09 06:38:42

标签: javascript angularjs

我想做相同的

windows.history.pushState({data: $scope.index}, "", "/winner");

$location.state({data: $scope.index})有效,但不是我想要的。

2 个答案:

答案 0 :(得分:1)

$location.state({data: $scope.index}).path('/winner')

答案 1 :(得分:1)

$locationpath方法可让您更改路径,因此您可以执行$location.path('/winner')。它的方法也是可链接的,因此您可以按如下方式组合状态和路径:

$location
  .state({data: $scope.index})
  .path('/winner')
相关问题