Something I can not understand what the problem is. There is such a simple piece of code:

return $q(function load(resolve, reject) { var source = nextSource(); var api = getById(source.resourceId); if (!loadedSources[index]) { api.promiseLoadContentPart(source).then(function(result) { if (result == 'error') { reject(false); } else if (result == 'loaded' || callbackStopLoading()) { loadedSources[index] = true; resolve(true); } else { load(); } }); } }); 

And it works as it should, until it comes to

 resolve(true); 

Which falls with such an error:

angular.js: 13920 TypeError: resolve is not a function

Actually, what's the problem?

  • one
    load(); - called without parameters. therefore inside the call, resolve and reject will be undefined - Grundy
  • There is such a simple piece of code: - the code is far from simple, with the recursive promise you still have to figure it out - Grundy
  • @Grundy, for sure, thanks, as I could have missed such an error ... - Ilya Bizunov

0