Skip to content Skip to sidebar Skip to footer

How To Make Angular Ui-router's Parent State Always Execute Controller Code When State Changes?

Let's say we have a parent-child relationship defined in our $stateProvider as follows: .state('myProfile', { url: '/my/profile', templateUrl: 'my/profile.html'

Solution 1:

To force a parent state to reload when navigate to him from a child state you can use both ways below. Pure js or a directive attribute.

<aui-sref="myProfile"ui-sref-opts="{ reload: true }">Back to My Profile</a>

or

$state.go('myProfile', null, { reload: true });

Solution 2:

Have you tried listening for the "$stateChangeStart" event and/or using $state.reload() ?

Solution 3:

Seems like there is a bug on $state.go which is leaving out the reload options. $state.transitionTo however works for me.

$state.transitionTo('state',null,{reload: true});

Post a Comment for "How To Make Angular Ui-router's Parent State Always Execute Controller Code When State Changes?"