In my scenario, I have controllers A
and B
located in different states.
When I trigger $state.go('state_b');
, Angular switches to state state_b
and loads controller B
. However, what surprises me is that I do not receive $stateChangeSuccess
in my B
controller.
Why is it that my B
controller is not receiving the $stateChangeSuccess
event triggered by $state.go
from controller A
?
Is there an alternative method for the B
controller to detect when it is being displayed? (It doesn't matter which previous state was active, just that the state/controller B
is active once again)
Below are the state definitions:
.state("state_b", {
url: "b/?:id",
templateUrl:"/template/cms/shared/tabs/genericView.html.twig",
reloadOnSearch: false,
moduleName: "Module B",
componentName: "Component B",
parent: "application"
})
.state("state_a", {
url: "a/",
templateUrl: "/template/bundlename/a/index.html.twig",
moduleName: "Module A",
componentName: "Component A",
parent: "application",
controller: "OohAController as a",
resolve: {
b: function(OohBService, OohActiveBService) {
var bId = OohActiveBService.getActiveB();
return OohAService.get({id: bId}).$promise;
}
}
})