I have an AngularJS controller that loads data from a service (performs asynchronous requests $http
).
And in the child controller, I need to wait for this data to load before I can make another request $http
to download more detailed information.
I tried to do this in the child controller:
$scope.$parent.watch('dataLoaded', function(dataLoaded) {
if (dataLoaded) {
}
};
When I do this, it works in the child controller, but it seems that this "dataLoaded" variable (which goes from false to true as soon as the data is loaded into the parent controller) never has the value actually changed to true in the parent controller.
What am I doing wrong? Should I use a completely different approach?