2

I need to intercept the change of ng-view and load a "loading div" overlay untill all new images are loaded.

I'm trying to suspend promises callbacks in my HttpInterceptor but I can't resolve my promise in a second time.

Here an example:

return function (promise) {
    globalForTest = $q.defer();

    return promise.then(function (response) {
        console.log('first', response);
        return globalForTest.promise;
    }).then(function (response) {
        console.log('second', response);
        return response;
    });

http://jsfiddle.net/Lmvjh/

When I try to call globalForTest.resolve(value) nothing happens, neither an error.

1 Answer 1

5

It works, but since your invoking resolve outside of angular lifecycle, you need to explicitly call $scope.$apply to set things in motion. Otherwise callbacks won't be invoked.

Link to fixed JSFiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.