Make a scope inside a function global

Im tryin to access my $rootScope.newBloodneeded but I cant access it outside the function, I tried rootscope so I can call it as global but still it gives me undefined

.controller('editbloodrequestCtrl', function($scope,Bloodrequest,$rootScope,$routeParams) {
$rootScope.newBloodneeded;

Bloodrequest.getBloodrequest($routeParams.id).then(function(data) {
        if (data.data.success) {
            $scope.newBloodneeded = data.data.bloodrequest.blood_component;
            $rootScope.newBloodneeded = $scope.newBloodneeded;
            //gives me output when I console here
        } else {
            app.errorMsg = data.data.message; // Set error message
        }
    });

console.log($rootScope.newBloodneeded); //gives me undefined

}

Source: AngularJS