Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using UI-Router and multiple nested named views. One of my pages, Company, has a sub section concerning Jobs. Jobs need to know the active Company, as well as access to a slew of other services that aren't really part of Company.

The straight forward approach is to throw everything into Company and inject all needed services there, but I'd like to separate and keep the Job sub section in its own view. My issue is here the Company page allows for navigation across multiple Companies, and I don't know a clean way to inform the Job view of the active Company change. Right now I am using a rootScope Broadcast, and it's really dirty and looks like it'll cause me issues down the road.

  1. How can I notify a child view that the parent's data has changed, and pass along an updated parameter at that time?
share|improve this question
    
Can you provide some sample code? Have you tried injecting the parent controller and using $scope.$watch ? –  Sebastian Homeier yesterday
    
$scope.$watch sounds like it should work but doesn't seems all that much cleaner than a $broadcast. I'll try it out, thanks @SebastianHomeier. I tried messing around with $stateParams but the Job controller wouldn't know when that updated... –  Joshua Ohana yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.