I am seeking guidance on how to handle resource loading errors in ocLazyLoading. I have attempted to load some resources within the resolve section of my $stateProvider
. One file, ctrl.js
, loads successfully. However, another file, iam-not-there.js
, fails to load due to its nonexistence.
My objective is to manage this "loading" error by continuing with the resolve process even if a resource loading error occurs. I want to be able to handle or catch a resource loading error effectively. Currently, everything works smoothly when all resources can be loaded. Yet, if one resource encounters an issue during loading, the application fails to progress to the resolve state. You can replicate this problem using the following plnkr example.
var myApp = angular.module("myApp", ['ui.router', 'oc.lazyLoad']);
myApp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('login', {
url: '/',
templateUrl: 'template.html',
controller: 'LoginController',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: "myApp",
files: [
'ctrl.js',
'iam-not-there.js'
]
});
}]
}
});
$urlRouterProvider.otherwise('/');
});