In my ControllerA i have an init() function which loads these services:
init(){
childrenDataService.getData($scope.family_id).then(function(result) {
$scope.childrenName = result;
$scope.selectedChild = result[0];
})
console.log($scope);
console.log($scope.selectedChild)
//this doesn't work => TypeError: Cannot read property 'id' of undefined
//can't access $scope.selectedChild.id
additonalDataService.getData($scope.selectedChild.id).then(function(result){
scope.additional = result;
})
}
The loading of ChildrenDataService is working fine. My Problem is that console.log($scope) gives me the full object. The attribute $scope.selectedChild is filled with an object.
But when I try to access this directly through console.log($scope.selectedChild) i get 'undefined'.
Why can't I access this directly? I need to access this because additonalDataService depends on the default selection of childrenDataService.
Thanks for your help