Skip to content

Commit

Permalink
fix($state): change default value of inherit option to true
Browse files Browse the repository at this point in the history
Since angular-ui#970, `href()` method takes into account the `inherit` option. This option needs to have a `true` default value in order to not introduce a breaking change.

Moreover, the `true` value is more convenient for this "high-level oriented" method.
  • Loading branch information
ncuillery committed May 30, 2014
1 parent 80766cd commit 84152e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand All @@ -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 || {});
Expand Down
2 changes: 1 addition & 1 deletion test/stateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}));
Expand Down

0 comments on commit 84152e0

Please sign in to comment.