diff --git a/src/state.js b/src/state.js index 3d8db8b65..cd55fa80a 100644 --- a/src/state.js +++ b/src/state.js @@ -475,7 +475,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ var nav = (state && options.lossy) ? state.navigable : state; var url = (nav && nav.url) ? nav.url.format(normalize(state.params, params || {})) : null; if (!$locationProvider.html5Mode() && url) { - url = "#" + url; + url = "#" + $locationProvider.hashPrefix() + url; } if (options.absolute && url) { url = $location.protocol() + '://' + diff --git a/test/stateSpec.js b/test/stateSpec.js index e7f48433d..deac94f79 100644 --- a/test/stateSpec.js +++ b/test/stateSpec.js @@ -613,6 +613,11 @@ describe('state', function () { locationProvider.html5Mode(true); expect($state.href("about.sidebar", null, { absolute: true })).toEqual("http://server/about"); })); + + it('respects $locationProvider.hashPrefix()', inject(function ($state) { + locationProvider.hashPrefix("!"); + expect($state.href("home")).toEqual("#!/"); + })); }); describe('.get()', function () {