I have the state brand. On the template of this state, I have some breadcrumbs. When I go to the nested state brand.collections for example, I need to update the breadcrumbs in the brand state.
How can I accomplish this?
.state('brand', {
url: '/brands/:brandId/:brandName',
templateUrl: 'js/modules/brands/partials/brand.html',
controller: 'BrandController',
})
.state('brand.home', {
url: '/home',
templateUrl: 'js/modules/brands/partials/brand.home.html',
controller: 'BrandController'
})
.state('brand.collections', {
url: '/collections',
template: 'Some collections',
controller: 'CollectionsController'
})
inside CollectionsController
$scope.$emit('changeParentVar',<newVal>);
inside BrandController
$scope.$on('changeParentVar',function(event,newVal){
event.stopPropagation();
variable = newVal;
});
Reference http://docs.angularjs.org/api/ng.$rootScope.Scope#methods_$on
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With