Skip to content

Commit 6fc0e32

Browse files
committed
Refactoring $state.go() functionality into transitionTo() as options.
1 parent ab17ce5 commit 6fc0e32

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/state.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,16 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
200200
};
201201

202202
$state.go = function go(to, params, options) {
203-
var toState = findState(to, $state.$current);
204-
params = inheritParams($stateParams, params || {}, $state.$current, toState);
205-
return this.transitionTo(toState, params, options);
203+
return this.transitionTo(to, params, extend({ inherit: true, relative: $state.$current }, options));
206204
};
207205

208206
$state.transitionTo = function transitionTo(to, toParams, options) {
209207
if (!isDefined(options)) options = (options === true || options === false) ? { location: options } : {};
210-
options = extend({ location: true, inherit: false });
208+
options = extend({ location: true, inherit: false, relative: null }, options);
211209

212-
to = findState(to);
210+
to = findState(to, options.relative);
213211
if (to['abstract']) throw new Error("Cannot transition to abstract state '" + to + "'");
212+
if (options.inherit) toParams = inheritParams($stateParams, toParams || {}, $state.$current, to);
214213

215214
var toPath = to.path,
216215
from = $state.$current, fromParams = $state.params, fromPath = from.path;

0 commit comments

Comments
 (0)