|
| 1 | +(function () { |
| 2 | + 'use strict'; |
| 3 | + |
| 4 | + /** |
| 5 | + * Introduce the austackApp.application module |
| 6 | + * and configure it. |
| 7 | + * |
| 8 | + * @requires ui.router |
| 9 | + * @requires ngResource |
| 10 | + * @requires austackApp.application.main |
| 11 | + * @requires austackApp.application.list |
| 12 | + * @requires austackApp.application.create |
| 13 | + */ |
| 14 | + angular |
| 15 | + .module('austackApp.application', [ |
| 16 | + 'ngResource', |
| 17 | + 'ui.router', |
| 18 | + 'austackApp.application.list', |
| 19 | + 'austackApp.application.detail', |
| 20 | + 'austackApp.application.edit', |
| 21 | + 'austackApp.application.create' |
| 22 | + ]) |
| 23 | + .config(configApplicationRoutes); |
| 24 | + |
| 25 | + // inject configApplicationRoutes dependencies |
| 26 | + configApplicationRoutes.$inject = ['$urlRouterProvider', '$stateProvider']; |
| 27 | + |
| 28 | + /** |
| 29 | + * Route configuration function configuring the passed $stateProvider. |
| 30 | + * Register the abstract application state with the application template |
| 31 | + * paired with the ApplicationController as 'index'. |
| 32 | + * The injectable 'applications' is resolved as a list of all applications |
| 33 | + * and can be injected in all sub controllers. |
| 34 | + * |
| 35 | + * @param {$stateProvider} $stateProvider - The state provider to configure |
| 36 | + */ |
| 37 | + function configApplicationRoutes($urlRouterProvider, $stateProvider) { |
| 38 | + // The application state configuration |
| 39 | + var applicationState = { |
| 40 | + name: 'application', |
| 41 | + parent: 'root', |
| 42 | + url: '/applications', |
| 43 | + abstract: true, |
| 44 | + resolve: { |
| 45 | + applications: resolveApplications |
| 46 | + }, |
| 47 | + templateUrl: 'app/application/application.html', |
| 48 | + controller: 'ApplicationController', |
| 49 | + controllerAs: 'index' |
| 50 | + }; |
| 51 | + |
| 52 | + //$urlRouterProvider.when('/application', '/application/'); |
| 53 | + $stateProvider.state(applicationState); |
| 54 | + } |
| 55 | + |
| 56 | + // inject resolveApplications dependencies |
| 57 | + resolveApplications.$inject = ['Application']; |
| 58 | + |
| 59 | + /** |
| 60 | + * Resolve dependencies for the application.list state |
| 61 | + * |
| 62 | + * @params {Application} Application - The service to query applications |
| 63 | + * @returns {Promise} A promise that, when fullfilled, returns an array of applications |
| 64 | + */ |
| 65 | + function resolveApplications(Application) { |
| 66 | + return Application.query().$promise; |
| 67 | + } |
| 68 | + |
| 69 | +})(); |
0 commit comments