Here's the scenario I'm dealing with:
Consider having two nested controllers structured like this:
Controller1
Controller2
In Controller1, there is a field
someDataService.getMyUser().then(function(user){
$scope.user = user;
}
This field retrieves data from an external server asynchronously. Everything seems fine so far. However, how can I handle the following situation:
I require the use of
var userName = $scope.$parent.user.userName
in Controller2 immediately when it initiates. How do I ensure that the second controller waits for the promise in the first controller to be resolved before assigning the value to var userName? Otherwise, $scope.$parent would return as undefined)