-
Notifications
You must be signed in to change notification settings - Fork 508
Description
I've been using requirejs to dynamically load angular controllers/services/etc... for a while but just recently added ocLazyLoad because of the ability to load modules as well. First I'd like to say thanks for the awesome work. Now here comes the issue:
I see that the jsLoader is being called with the following signature
function (paths, callback, params)and is expecting that the error (if any) is passed as the first parameter to the callback, but requirejs actually has the following signature
function (deps, callback, errback, optional)`In this case, callback is call with the return of the define function (if any) and errback will be called with an error object if an error has occurred. This leads to the following issue, If requirejs encounters an error (for example, a 404), then the promise is never resolved or rejected.
I've worked around this with adding the errback to jsLoader call as follows:
if (jsFiles.length > 0) {
var jsDeferred = $q.defer();
$delegate.jsLoader(jsFiles, function (err) {
if (angular.isDefined(err) && $delegate.jsLoader.hasOwnProperty("ocLazyLoadLoader")) {
$delegate._$log.error(err);
jsDeferred.reject(err);
} else {
jsDeferred.resolve();
}
}, function(err) {
jsDeferred.reject(err);
}, params);
promises.push(jsDeferred.promise);
}Please let me know what you think