Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,11 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
location: true, inherit: false, relative: null, notify: true, reload: false, $retry: false
}, options || {});

var from = $state.$current, fromParams = $state.params, fromPath = from.path;
var from = $state.$current,
fromResolved = from.locals,
fromParams = $state.params,
fromPath = from.path;

var evt, toState = findState(to, options.relative);

if (!isDefined(toState)) {
Expand Down Expand Up @@ -870,7 +874,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
// and return a promise for the new state. We also keep track of what the
// current promise is, so that we can detect overlapping transitions and
// keep only the outcome of the last transition.
var transition = $state.transition = resolved.then(function () {
var transition = $state.transition = resolved.then(function (toResolved) {
var l, entering, exiting;

if ($state.transition !== transition) return TransitionSuperseded;
Expand Down Expand Up @@ -924,7 +928,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
* @param {State} fromState The current state, pre-transition.
* @param {Object} fromParams The params supplied to the `fromState`.
*/
$rootScope.$broadcast('$stateChangeSuccess', to.self, toParams, from.self, fromParams);
$rootScope.$broadcast('$stateChangeSuccess', to.self, toParams, toResolved, from.self, fromParams, fromResolved);
}
$urlRouter.update(true);

Expand Down
9 changes: 7 additions & 2 deletions test/stateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ describe('state', function () {
function eventLogger(event, to, toParams, from, fromParams) {
if (logEvents) log += event.name + '(' + to.name + ',' + from.name + ');';
}

function eventLoggerSuccess(event, to, toParams, toResolved, from, fromParams, fromResolved) {
if (logEvents) log += event.name + '(' + to.name + ',' + from.name + ');';
}

function callbackLogger(what) {
return function () {
if (logEnterExit) log += this.name + '.' + what + ';';
Expand Down Expand Up @@ -111,7 +116,7 @@ describe('state', function () {
log = '';
logEvents = logEnterExit = false;
$rootScope.$on('$stateChangeStart', eventLogger);
$rootScope.$on('$stateChangeSuccess', eventLogger);
$rootScope.$on('$stateChangeSuccess', eventLoggerSuccess);
$rootScope.$on('$stateChangeError', eventLogger);
$rootScope.$on('$stateNotFound', eventLogger);
}));
Expand Down Expand Up @@ -309,7 +314,7 @@ describe('state', function () {
it('triggers $stateChangeSuccess', inject(function ($state, $q, $rootScope) {
initStateTo(E, { i: 'iii' });
var called;
$rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, from, fromParams) {
$rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, toResolved, from, fromParams, fromResolved) {
expect(from).toBe(E);
expect(fromParams).toEqual({ i: 'iii' });
expect(to).toBe(D);
Expand Down