在locationChangeStart上追加Param

时间:2015-07-06 18:13:20

标签: angularjs

当用户例如点击我的应用程序的后退按钮时,我会执行window.history.back(),这里触发locationChangeStart,我想按照此主题附加.search({param:'value'}):{ {3}}

这可以吗?

编辑:

这就是我的尝试:

            ]).config(appRoute).run(function ($rootScope, $route) {
                $rootScope.passArgs = {};
                ang.rootScope = $rootScope;
                ang.route = $route;

                $rootScope.$on('$locationChangeStart', function (a, b, c) {
                    for (var aArg in $rootScope.passArgs) {
                        $route.current.params[aArg] = $rootScope.passArgs[aArg];
                        delete $rootScope.passArgs[aArg];
                    }
                });

1 个答案:

答案 0 :(得分:1)

你可以这样做,而不是一英里。

<button class="back-button" ng-click="back()">Go back</button>

$scope.back = function() {
  $location.path('my-path').search({isBack: true});
}