Imagine having two states configured using angularjs ui-router:
.state('branding', {
url: "/{branding}",
controller: 'BrandingCtrl',
templateUrl: '/app/Branding.html'
})
.state('branding.index', {
url: "/index",
controller: 'IndexCtrl',
templateUrl: '/app/Index.html'
})
Inside the BrandingCtrl
, the page details are set up along with user access verification. If access is denied, $state.go('someotherstate') is used to redirect them.
If a user navigates to /badbranding/index, the BrandingCtrl
detects the lack of access and changes the state. However, the IndexCtrl
still runs, despite the parent controller already changing the state.
How can ui-router be instructed to cancel the execution of nested states?