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
This commit is contained in:
David Reher 2016-01-26 13:51:50 +01:00 committed by Igor Minar
parent 72ab35bceb
commit e73fee7156
2 changed files with 4 additions and 4 deletions

View File

@ -303,8 +303,8 @@ Location.prototype.subscribe = function () {
//TODO: implement //TODO: implement
}; };
Location.prototype.path = function () { Location.prototype.path = function () {
return $location.path(); return $location.url();
}; };
Location.prototype.go = function (url) { Location.prototype.go = function (path, query) {
return $location.path(url); return $location.url(path + query);
}; };

View File

@ -57,7 +57,7 @@ function routerFactory($q, $location, $$directiveIntrospector, $browser, $rootSc
}); });
var router = new RootRouter(registry, location, $routerRootComponent); 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) { if (router.lastNavigationAttempt !== path) {
router.navigateByUrl(path); router.navigateByUrl(path);
} }