TypeError: not a function

TypeError: not a function

我在调用下面的 userRequest 函数时遇到类型错误 -

angular.min.js:107 TypeError: $scope.userRequest.then is not a function

$scope.userRequest = function() {
    if ($scope.realm === 'example') {
        return service.getUserDetails($scope.username)
            .then(function(data) {
                ...
                return data;
            });
    } else {
        return $q.reject($scope.realm + ' not supported');
    }
};
$scope.userRequest.then(function(user) {
    return service.getUserRides(user.email);
}).then(function(data) {
   ...
}).catch(function(error) {
   ...
})

请告诉我如何修复错误?

调用函数获取承诺:

̶$̶s̶c̶o̶p̶e̶.̶u̶s̶e̶r̶R̶e̶q̶u̶e̶s̶t̶.̶t̶h̶e̶n̶(̶f̶u̶n̶c̶t̶i̶o̶n̶(̶u̶s̶e̶r̶)̶ ̶{̶
$scope.userRequest().then(function(user) {
    return service.getUserRides(user.email);
}).then(function(data) {
   //...
}).catch(function(error) {
   //...
})