From fbeb3fd3624b6f732e7c582b1b3cc946378ca773 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Fri, 7 Jul 2017 22:31:49 +0200 Subject: [PATCH] Separate app.config in another file. --- src/app.config.js | 22 ++++++++++++++++++++++ src/app.js | 31 ++++--------------------------- 2 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 src/app.config.js diff --git a/src/app.config.js b/src/app.config.js new file mode 100644 index 0000000..1d051d5 --- /dev/null +++ b/src/app.config.js @@ -0,0 +1,22 @@ +module.exports = function($routeProvider) { + // Defining template and controller in function of route. + $routeProvider + .when('/account/:accountId/operations', { + templateUrl: operationsTmpl, + controller: 'OperationController', + controllerAs: 'operationsCtrl' + }) + .when('/account/:accountId/scheduler', { + templateUrl: schedulerTmpl, + controller: 'SchedulerController', + controllerAs: 'schedulerCtrl' + }) + .when('/accounts', { + templateUrl: accountsTmpl, + controller: 'AccountController', + controllerAs: 'accountsCtrl' + }) + .otherwise({ + redirectTo: '/accounts' + }); +}; diff --git a/src/app.js b/src/app.js index 7af9bcf..433f947 100644 --- a/src/app.js +++ b/src/app.js @@ -27,41 +27,18 @@ var accountModule = require('./accounts'), operationModule = require('./operations'), schedulerModule = require('./scheduler'); +var routing = require('./app.config'); + require('bootstrap-webpack!./bootstrap.config.js'); var operationsTmpl = require('./operations/operations.html'); var accountsTmpl = require('./accounts/accounts.html'); var schedulerTmpl = require('./scheduler/scheduler.html'); -var app = angular.module('accountant', [ +angular.module('accountant', [ accountModule, loginModule, operationModule, schedulerModule, ngRoute, -]) - - .config(function($routeProvider) { - // Defining template and controller in function of route. - $routeProvider - .when('/account/:accountId/operations', { - templateUrl: operationsTmpl, - controller: 'OperationController', - controllerAs: 'operationsCtrl' - }) - .when('/account/:accountId/scheduler', { - templateUrl: schedulerTmpl, - controller: 'SchedulerController', - controllerAs: 'schedulerCtrl' - }) - .when('/accounts', { - templateUrl: accountsTmpl, - controller: 'AccountController', - controllerAs: 'accountsCtrl' - }) - .otherwise({ - redirectTo: '/accounts' - }); - }); - -module.exports = app; +]).config(routing);