From e73fee715668740f1579093f61fea0f08d44da18 Mon Sep 17 00:00:00 2001 From: David Reher Date: Tue, 26 Jan 2016 13:51:50 +0100 Subject: [PATCH] fix(router): fixed the location wrapper for angular1 In angular2 `Location.path()` returns the complete path including query string. In angular1 the query parameters are missing. Similar to this `Location.go` does accept two parameters (path *and query*). Closes #6943 --- modules/angular1_router/lib/facades.es5 | 6 +++--- modules/angular1_router/src/module_template.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/angular1_router/lib/facades.es5 b/modules/angular1_router/lib/facades.es5 index f419cdef5f..b84d86bf36 100644 --- a/modules/angular1_router/lib/facades.es5 +++ b/modules/angular1_router/lib/facades.es5 @@ -303,8 +303,8 @@ Location.prototype.subscribe = function () { //TODO: implement }; Location.prototype.path = function () { - return $location.path(); + return $location.url(); }; -Location.prototype.go = function (url) { - return $location.path(url); +Location.prototype.go = function (path, query) { + return $location.url(path + query); }; diff --git a/modules/angular1_router/src/module_template.js b/modules/angular1_router/src/module_template.js index 43415af4d5..0139664bc7 100644 --- a/modules/angular1_router/src/module_template.js +++ b/modules/angular1_router/src/module_template.js @@ -57,7 +57,7 @@ function routerFactory($q, $location, $$directiveIntrospector, $browser, $rootSc }); var router = new RootRouter(registry, location, $routerRootComponent); - $rootScope.$watch(function () { return $location.path(); }, function (path) { + $rootScope.$watch(function () { return $location.url(); }, function (path) { if (router.lastNavigationAttempt !== path) { router.navigateByUrl(path); }