Skip to content

Commit 7344342

Browse files
fix($state): reload() now reinvokes controllers
- change reload() to use notify: true fixes #582
1 parent fdd2f2c commit 7344342

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/state.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -632,15 +632,15 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
632632
* `reload()` is just an alias for:
633633
* <pre>
634634
* $state.transitionTo($state.current, $stateParams, {
635-
* reload: true, inherit: false, notify: false
635+
* reload: true, inherit: false, notify: true
636636
* });
637637
* </pre>
638638
*
639639
* @returns {promise} A promise representing the state of the new transition. See
640640
* {@link ui.router.state.$state#methods_go $state.go}.
641641
*/
642642
$state.reload = function reload() {
643-
return $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: false });
643+
return $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: true });
644644
};
645645

646646
/**

test/stateSpec.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('state', function () {
1717
};
1818
}
1919

20-
var A = { data: {} },
20+
var A = { data: {}, controller: function() { log += "controller;"; } },
2121
B = {},
2222
C = {},
2323
D = { params: { x: null, y: null } },
@@ -95,7 +95,8 @@ describe('state', function () {
9595
value: function ($timeout) {
9696
return $timeout(function() { log += "Success!"; }, 1);
9797
}
98-
}
98+
},
99+
controller: function() { log += "controller;"}
99100
})
100101
.state('badParam', {
101102
url: "/bad/{param:int}"
@@ -515,6 +516,19 @@ describe('state', function () {
515516
$timeout.flush();
516517
expect(log).toBe('Success!Success!');
517518
}));
519+
520+
it('should invoke the controller', inject(function ($state, $q, $timeout, $rootScope, $compile) {
521+
$compile('<div ui-view/>')($rootScope);
522+
$state.transitionTo('resolveTimeout', { foo: "bar" });
523+
$timeout.flush();
524+
$q.flush();
525+
expect(log).toBe('Success!controller;');
526+
527+
$state.reload();
528+
$timeout.flush();
529+
$q.flush();
530+
expect(log).toBe('Success!controller;Success!controller;');
531+
}));
518532
});
519533

520534
describe('.is()', function () {

0 commit comments

Comments
 (0)