Skip to content

Commit

Permalink
Merge pull request #1337 from cesarandreu/master
Browse files Browse the repository at this point in the history
feat($state): .reload() returns state transition promise
  • Loading branch information
nateabele committed Sep 5, 2014
2 parents eb1712b + 639e056 commit 7d51c4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,12 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
* reload: true, inherit: false, notify: false
* });
* </pre>
*
* @returns {promise} A promise representing the state of the new transition. See
* {@link ui.router.state.$state#methods_go $state.go}.
*/
$state.reload = function reload() {
$state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: false });
return $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: false });
};

/**
Expand Down
10 changes: 10 additions & 0 deletions test/stateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,16 @@ describe('state', function () {
});

describe('.reload()', function () {
it('returns a promise for the state transition', inject(function ($state, $q) {
var trans = $state.transitionTo(A, {});
$q.flush();
expect(resolvedValue(trans)).toBe(A);

trans = $state.reload();
$q.flush();
expect(resolvedValue(trans)).toBe(A);
}));

it('should reload the current state with the current parameters', inject(function ($state, $q, $timeout) {
$state.transitionTo('resolveTimeout', { foo: "bar" });
$q.flush();
Expand Down

0 comments on commit 7d51c4a

Please sign in to comment.