app.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. 'use strict';
  2. // Declare app level module which depends on filters, and services
  3. var App = angular.module('app', ['ui.router', 'oc.lazyLoad'])
  4. .config(function($stateProvider, $locationProvider, $urlRouterProvider, $ocLazyLoadProvider) {
  5. $urlRouterProvider.otherwise("/");
  6. $locationProvider.hashPrefix('!');
  7. // You can also load via resolve
  8. $stateProvider
  9. .state('index', {
  10. url: "/", // root route
  11. views: {
  12. "lazyLoadView": {
  13. controller: 'AppCtrl', // This view will use AppCtrl loaded below in the resolve
  14. templateUrl: 'partials/main.html'
  15. }
  16. },
  17. resolve: { // Any property in resolve should return a promise and is executed before the view is loaded
  18. loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
  19. // you can lazy load files for an existing module
  20. return $ocLazyLoad.load('js/AppCtrl.js');
  21. }]
  22. }
  23. })
  24. .state('modal', {
  25. parent: 'index',
  26. resolve: { // Any property in resolve should return a promise and is executed before the view is loaded
  27. loadOcModal: ['$ocLazyLoad', '$injector', '$rootScope', function($ocLazyLoad, $injector, $rootScope) {
  28. // Load 'oc.modal' defined in the config of the provider $ocLazyLoadProvider
  29. return $ocLazyLoad.load([
  30. 'bower_components/bootstrap/dist/css/bootstrap.css', // will use the cached version if you already loaded bootstrap with the button
  31. 'bower_components/ocModal/dist/css/ocModal.animations.css',
  32. 'bower_components/ocModal/dist/css/ocModal.light.css',
  33. 'bower_components/ocModal/dist/ocModal.js',
  34. 'partials/modal.html'
  35. ]).then(function() {
  36. $rootScope.bootstrapLoaded = true;
  37. // inject the lazy loaded service
  38. var $ocModal = $injector.get("$ocModal");
  39. $ocModal.open({
  40. url: 'modal',
  41. cls: 'fade-in'
  42. });
  43. });
  44. }],
  45. // resolve the sibling state and use the service lazy loaded
  46. setModalBtn: ['loadOcModal', '$rootScope', '$ocModal', function(loadOcModal, $rootScope, $ocModal) {
  47. $rootScope.openModal = function() {
  48. $ocModal.open({
  49. url: 'modal',
  50. cls: 'flip-vertical'
  51. });
  52. }
  53. }]
  54. }
  55. });
  56. // Without server side support html5 must be disabled.
  57. $locationProvider.html5Mode(false);
  58. // We configure ocLazyLoad to use the lib script.js as the async loader
  59. $ocLazyLoadProvider.config({
  60. debug: true,
  61. events: true,
  62. modules: [{
  63. name: 'gridModule',
  64. files: [
  65. 'js/gridModule.js'
  66. ]
  67. }]
  68. });
  69. });