Last active
August 29, 2015 14:07
-
-
Save charandas/35b51979d7e1291ef34b to your computer and use it in GitHub Desktop.
futureStates.addResolve is enough for some of us with ocLazyLoad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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