Last active
May 30, 2016 01:06
-
-
Save diegochavez/7dba5061795965b43d370246586d1b17 to your computer and use it in GitHub Desktop.
This file contains 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
import angular from 'angular'; | |
import uiRouter from 'angular-ui-router'; | |
import ocLazyLoad from 'oclazyload'; | |
let aboutModule = angular.module('about', [ | |
uiRouter, | |
ocLazyLoad | |
]) | |
.config(($stateProvider, $compileProvider) => { | |
"ngInject"; | |
$stateProvider | |
.state('about', { | |
url: '/about', | |
views:{ | |
topbar: { | |
template: "<topbar></topbar>" | |
}, | |
sidebar: { | |
template: "<sidebar></sidebar>" | |
}, | |
content: { | |
template: "<about></about>" | |
}, | |
footer: { | |
template: "<footer></footer>" | |
} | |
}, | |
resolve: { | |
loadComponent: ($q, $ocLazyLoad) => { | |
var deferred = $q.defer(); | |
// Webpack will define a code-split point for all requires in this callback | |
// This will effectively bundle this entire module into a single file | |
// that only gets downloaded when this state is transitioned to | |
require.ensure([], function(require) { | |
// Require our modules | |
// This replaces the `import` statements from above | |
//let something = require('./about.something'); | |
// .. any other dependencies | |
let component = require('./about.component'); | |
// Inject all dependencies into our module | |
// This replaces adding them to the original angular.module dependency array | |
$ocLazyLoad.inject([ | |
// something.name | |
// .. any other dependencies | |
]) | |
// Register the component so the template recognizes it | |
.then(() => $compileProvider.component('about', component)) | |
// Continue the state transition | |
.then(deferred.resolve()); | |
}, 'about'); // Name our bundle so it shows up pretty in the network tab | |
return deferred.promise | |
} | |
} | |
}); | |
}) | |
//.component('about', component); | |
export default aboutModule; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment