Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaugth TypeError: Cannot read property 'then' of undefined #4

Open
cheskos opened this issue Jun 3, 2016 · 1 comment
Open

Uncaugth TypeError: Cannot read property 'then' of undefined #4

cheskos opened this issue Jun 3, 2016 · 1 comment

Comments

@cheskos
Copy link

cheskos commented Jun 3, 2016

Hello.

I am getting the error in this block.

if (!scope.pullToRefreshActive) {
   scope.pullToRefreshActive = true;
   scope.refreshFunction().then(function () {
       scope.pullToRefreshActive = false;
   });
   scope.$digest();
}

Really have no clue of what's going on because at runtime the scope object does have the function defined as:

function (locals) {
     return parentGet(scope, locals);
}

Thanks

@datenwort
Copy link

datenwort commented Dec 12, 2016

I had the same error. The refreshFunction expects a promise as return.
The sample shows the following.

$scope.refreshFunction = function() {
    var deferred = $q.defer();
    setTimeout(function() {
        $scope.randomItem();
        deferred.resolve(true);
    }, 2000);
    return deferred.promise;
};

So you could put your function within the promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants