Skip to content

Instantly share code, notes, and snippets.

@charandas
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save charandas/35b51979d7e1291ef34b to your computer and use it in GitHub Desktop.

Select an option

Save charandas/35b51979d7e1291ef34b to your computer and use it in GitHub Desktop.
futureStates.addResolve is enough for some of us with ocLazyLoad
define([
'angular',
'angularUiRouter',
'uiRouterExtras',
'uiRouterExtrasStatevis',
'ocLazyLoad',
'boot/module',
'boot/services/settings',
'boot/services/listings'
], function (angular) {
'use strict';
return angular.module('raiiServicesExample',
[
'ui.router',
'ct.ui.router.extras',
'ct.ui.router.extras.examples.statevis',
'oc.lazyLoad',
'raiiServicesExample.boot',
]).config([
'$ocLazyLoadProvider',
'$futureStateProvider',
'SettingsServiceProvider',
'ListingServiceProvider',
function($ocLazyLoadProvider,
$futureStateProvider,
SettingsServiceProvider,
ListingServiceProvider) {
$ocLazyLoadProvider.config ({
debug: true,
jsLoader: requirejs,
loadedModules: ['raiiServicesExample'],
modules: [{
reconfig: true,
name: 'raiiServicesExample.states.core',
files: ['states/core']
}
});
$futureStateProvider.addResolve(function ($injector) {
/**
* NOTE:
*
* Important thing to remember: in addResolve, you have
* to "return" the thenable promise chain - as long as it could be
* keep it a chain ;)
*
*/
return $injector.invoke(SettingsServiceProvider.fruit).then(
function(fruitResult) {
return ListingServiceProvider.getAll(fruitResult);
}
).then(
function () {
return $ocLazyLoad.load('raiiServicesExample.states.core');
}
);
});
}]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment