Advertisement
Guest User

Untitled

a guest
May 29th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. import angular from 'angular';
  2. import uiRouter from 'angular-ui-router';
  3. import ocLazyLoad from 'oclazyload';
  4.  
  5. let aboutModule = angular.module('about', [
  6. uiRouter,
  7. ocLazyLoad
  8. ])
  9.  
  10. .config(($stateProvider, $compileProvider) => {
  11. "ngInject";
  12. $stateProvider
  13. .state('about', {
  14. url: '/about',
  15. views:{
  16. topbar: {
  17. template: "<topbar></topbar>"
  18. },
  19. sidebar: {
  20. template: "<sidebar></sidebar>"
  21. },
  22. content: {
  23. template: "<about></about>"
  24. },
  25. footer: {
  26. template: "<footer></footer>"
  27. }
  28. },
  29.  
  30. resolve: {
  31. loadComponent: ($q, $ocLazyLoad) => {
  32. var deferred = $q.defer();
  33.  
  34. // Webpack will define a code-split point for all requires in this callback
  35. // This will effectively bundle this entire module into a single file
  36. // that only gets downloaded when this state is transitioned to
  37. require.ensure([], function(require) {
  38.  
  39. // Require our modules
  40. // This replaces the `import` statements from above
  41. //let something = require('./about.something');
  42. // .. any other dependencies
  43. let component = require('./about.component');
  44.  
  45. // Inject all dependencies into our module
  46. // This replaces adding them to the original angular.module dependency array
  47. $ocLazyLoad.inject([
  48.  
  49. // something.name
  50. // .. any other dependencies
  51. ])
  52.  
  53. // Register the component so the template recognizes it
  54. .then(() => $compileProvider.directive('about', component))
  55. // Continue the state transition
  56. .then(deferred.resolve());
  57.  
  58. }, 'about'); // Name our bundle so it shows up pretty in the network tab
  59.  
  60. return deferred.promise
  61. }
  62. }
  63.  
  64. });
  65. })
  66.  
  67. //.component('about', component);
  68.  
  69. export default aboutModule;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement