I require the user details for multiple areas. I tried to return the details using a generic function. But i am getting the result as undefined. i understand that, I require to use the $differed to get the reuslt. But I don't have any idea about my current scenario.
anyone help me here please?
here is my function:
$scope.currentUserInfo = function () {
        var userDetails;
        server.getProfile.get().$promise.then(function ( response ) {
            if( response.Message.toUpperCase().indexOf('SUCCESS') != -1) {
                return  userDetails = response;
            }
            return "Not able to get the user details this time"
        })
        return userDetails;
    }
$scope.currentUser =  $scope.currentUserInfo();
console.log( $scope.currentUser ) //undefined.
var function1 = function () {
    $scope.currentUserInfo(); //once user details available do further
     $scope.age = $scope.currentUser.age;
}
var function2 = function () {
    $scope.currentUserInfo(); //once user details available do further
    $scope.name = $scope.currentUser.name;
}
 
    