Advertisement
mero909

Parent/Child Modules

Feb 3rd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     'use strict';
  3.  
  4.     /**
  5.      * The parent module that navigates you to any sub module.
  6.      */
  7.     angular
  8.         .module('indirect', [
  9.             'ui.router',
  10.             'indirect.config',
  11.             'indirect.determination',
  12.             'indirect.reports'
  13.         ])
  14.         .config(MainConfiguration);
  15.  
  16.     /**
  17.      * The parent module configuration that houses routing, translations, etc.
  18.      * @param {provider} $stateProvider - Handles state changes in the main SPA.
  19.      * @param {provider} $urlRouterProvider - Handles the default state.
  20.      * @param {provider} $translateProvider - Handles translations.
  21.      * @constructor
  22.      * @ngInject
  23.      **/
  24.     function MainConfiguration($stateProvider, $urlRouterProvider, $translateProvider) {
  25.         $stateProvider
  26.             .state('indirect.determination.home', {
  27.                 url: '/determination',
  28.                 templateUrl: 'js/components/home/indirect-view.html',
  29.                 controller: 'indirectHomeController',
  30.                 controllerAs: 'homeCtrl'
  31.             })
  32.             .state('indirect.reports.home', {
  33.                 url: '/reports',
  34.                 templateUrl: 'js/components/reports/reports-view.html',
  35.                 controller: 'reportsController',
  36.                 controllerAs: 'reportsCtrl'
  37.             });
  38.  
  39.         if(typeof(LoneStar) !== 'object') {
  40.             $translateProvider.useStaticFilesLoader({
  41.                 prefix: '/languages/indirect-',
  42.                 suffix: '.json'
  43.             });
  44.  
  45.             $translateProvider.preferredLanguage('en');
  46.             $urlRouterProvider.otherwise('indirect.determination.home');
  47.         }
  48.     }
  49.  
  50.     /**
  51.      * The determination sub module declaration.
  52.      */
  53.     angular
  54.         .module('indirect.determination', [
  55.             'ui.router',
  56.             'pascalprecht.translate',
  57.             'fef',
  58.             'bento.modern',
  59.             'tmh.dynamicLocale',
  60.             'wj',
  61.             'indirect.config',
  62.             'determination-templates'
  63.         ])
  64.         .config(Configuration);
  65.  
  66.     /**
  67.      * Configures angular components used within the application.
  68.      * @param {provider} $stateProvider - Handles state management in the application.
  69.      * @param {provider} $urlRouterProvider - Handles the default state of the
  70.      * @param {provider} $translateProvider - Handles all translations in the application.
  71.      * @constructor
  72.      * @ngInject
  73.      **/
  74.     function Configuration($stateProvider, $urlRouterProvider, $translateProvider) {
  75.         $stateProvider
  76.             .state('determination', {
  77.                 url: '/indirect',
  78.                 templateUrl: 'js/components/home/indirect-view.html',
  79.                 controller:  'indirectHomeController',
  80.                 controllerAs: 'indirect'
  81.             })
  82.             .state('determination.home', {
  83.                 url: '/home',
  84.                 templateUrl: 'js/components/dashboard/dashboard-view.html',
  85.                 controller: 'indirectDashboardController',
  86.                 controllerAs: 'indirectDashboard'
  87.             })
  88.             .state('determination.customers', {
  89.                  url: '/customers',
  90.                  templateUrl: 'js/components/exemption-certificates/customers/customers-view.html',
  91.                  controller: 'indirectCustomersController',
  92.                  controllerAs: 'indirectCustomers'
  93.             })
  94.             .state('determination.companies', {
  95.                 url: '/companies' ,
  96.                 templateUrl: 'js/components/configuration/companies/companies-view.html',
  97.                 controller: 'indirectCompaniesController' ,
  98.                 controllerAs: 'indirectCompanies'
  99.             })
  100.             .state('determination.taxJurisdictions', {
  101.                 url: '/taxJurisdictions',
  102.                 templateUrl: 'js/components/configuration/tax-jurisdictions/tax-jurisdictions-view.html',
  103.                 controller: 'indirectTaxJurisdictionsController',
  104.                 controllerAs: 'indirectTaxJurisdictions'
  105.             });
  106.  
  107.         if(typeof(LoneStar) !== 'object') {
  108.             $translateProvider.useStaticFilesLoader({
  109.                 prefix: '/languages/indirect-',
  110.                 suffix: '.json'
  111.             });
  112.  
  113.             $translateProvider.preferredLanguage('en');
  114.             $urlRouterProvider.otherwise('determination.companies');
  115.         }
  116.     }
  117.  
  118.     /**
  119.      * The reporting sub module declaration.
  120.      */
  121.     angular
  122.         .module('indirect.reports', ['ui.router'])
  123.         .config(ReportsConfiguration);
  124.  
  125.     /**
  126.      * Handles the state routing and the translations for the Reports module.
  127.      * @param {provider} $stateProvider - Handles state management in the application.
  128.      * @param {provider} $urlRouterProvider - Handles the default state of the
  129.      * @param {provider} $translateProvider - Handles all translations in the application.
  130.      * @constructor
  131.      * @ngInject
  132.      */
  133.     function ReportsConfiguration($stateProvider, $urlRouterProvider, $translateProvider) {
  134.         $stateProvider
  135.             .state('reports', {
  136.                 url: '/reports',
  137.                 templateUrl: 'js/components/reports/reports-view.html',
  138.                 controller: 'reportsController',
  139.                 controllerAs: 'reportsCtrl'
  140.             });
  141.  
  142.  
  143.         if(typeof(LoneStar) !== 'object') {
  144.             $translateProvider.useStaticFilesLoader({
  145.                 prefix: '/languages/indirect-',
  146.                 suffix: '.json'
  147.             });
  148.  
  149.             $translateProvider.preferredLanguage('en');
  150.             $urlRouterProvider.otherwise('reports');
  151.         }
  152.     }
  153. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement