.load() resolve before module dependencies loaded

Posted in General by Patrice Pechereau Thu Jun 11 2015 08:31:47 GMT+0000 (UTC)·Viewed 4,218 times

Hi, First, thank a lot for your good job. I have an issue with ocLazyLoading.load and modules dependencies. the code: file1.js : angular.module('mod1', [ {files:[ 'file2', 'file3'] } ]) .controller('mod1Ctrl', ['$scope', 'mod3Svc', function($scope, mod3Svc){ ... }) .factory('mod1Svc', ['mod3Svc', function(mod3Svc){ return { func1: function{ return mod3Svc.func1() } } }); file2.js : angular.module('mod2', [ {files:[ 'file3', 'file4'] } ]); file3.js : angular.module('mod3', [ ]) .factory('mod3Svc', function(){ return { func1: function(){ return true} }; }); file4.js : angular.module('mod4', [ ]); app.js : (loaded with page) angular.module('app', [ 'oc.lazyLoad', 'ui.router' ]) .config(['$stateProvider', '$ocLazyLoadProvider', function($stateProvider, $ocLazyLoadProvider){ $ocLazyLoadProvider.config({ debug: true, modules: [{ name: 'ocMod1', files: ['file1.js'] }] }); $stateProvider .state('state1', { url: '/state1', templateUrl: 'state1.html', controller: 'mod1Ctrl', resolve: { myResolve: ['$stateParams', '$ocLazyLoad', '$injector', '$log', function ($stateParams, $ocLazyLoad, $injector, $log) { return $ocLazyLoad.load('mod1').then(function () { $log.debug("$ocLazyLoad.load('mod1').then RESOLVE"); var service = $injector.get('mod1Svc'); return service.func1(); }); }] } }) }]); the issue : In some situation, not everytime, $ocLazyLoad.load(['mod1']) resolve before file3.js was loaded. Best regards, Patrice Pechereau (I am french (85))
  
Markdown is allowed