diff --git a/src/state.js b/src/state.js index 61cebed87..c70946046 100644 --- a/src/state.js +++ b/src/state.js @@ -1091,7 +1091,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { * - **`lossy`** - {boolean=true} - If true, and if there is no url associated with the state provided in the * first parameter, then the constructed href url will be built from the first navigable ancestor (aka * ancestor with a valid url). - * - **`inherit`** - {boolean=false}, If `true` will inherit url parameters from current url. + * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url. * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'), * defines which state to be relative from. * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl". @@ -1101,7 +1101,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { $state.href = function href(stateOrName, params, options) { options = extend({ lossy: true, - inherit: false, + inherit: true, absolute: false, relative: $state.$current }, options || {}); diff --git a/test/stateSpec.js b/test/stateSpec.js index 75e11f268..0c4d6bb6f 100644 --- a/test/stateSpec.js +++ b/test/stateSpec.js @@ -649,7 +649,7 @@ describe('state', function () { it('inherit url parameters from current url', inject(function ($state) { initStateTo($state.get('root'), {param1: 1}); - expect($state.href("root", {}, {})).toEqual("#/root"); + expect($state.href("root", {}, {})).toEqual("#/root?param1=1"); expect($state.href("root", {}, {inherit:false})).toEqual("#/root"); expect($state.href("root", {}, {inherit:true})).toEqual("#/root?param1=1"); }));