diff --git a/src/state.js b/src/state.js index ce7f49f43..3a2bf95d2 100644 --- a/src/state.js +++ b/src/state.js @@ -181,7 +181,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ if (!state['abstract'] && state.url) { $urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match, $stateParams) { if ($state.$current.navigable != state || !equalForKeys($match, $stateParams)) { - $state.transitionTo(state, $match, false); + $state.transitionTo(state, $match, { location: false }); } }]); } diff --git a/test/stateSpec.js b/test/stateSpec.js index 201a8c969..d52a36fca 100644 --- a/test/stateSpec.js +++ b/test/stateSpec.js @@ -689,6 +689,17 @@ describe('state', function () { expect($state.current.name).toBe('about.person'); })); + it('preserve hash', inject(function($state, $rootScope, $location) { + $location.path("/about/bob"); + $location.hash("frag"); + $rootScope.$broadcast("$locationChangeSuccess"); + $rootScope.$apply(); + expect($state.params).toEqual({ person: "bob" }); + expect($state.current.name).toBe('about.person'); + expect($location.path()).toBe('/about/bob'); + expect($location.hash()).toBe('frag'); + })); + it('should correctly handle absolute urls', inject(function ($state, $rootScope, $location) { $location.path("/first/subpath"); $rootScope.$broadcast("$locationChangeSuccess");