Separate app.config in another file.

This commit is contained in:
Alexis Lahouze 2017-07-07 22:31:49 +02:00
parent 2fb98fdeed
commit fbeb3fd362
2 changed files with 26 additions and 27 deletions

22
src/app.config.js Normal file
View File

@ -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'
});
};

View File

@ -27,41 +27,18 @@ var accountModule = require('./accounts'),
operationModule = require('./operations'), operationModule = require('./operations'),
schedulerModule = require('./scheduler'); schedulerModule = require('./scheduler');
var routing = require('./app.config');
require('bootstrap-webpack!./bootstrap.config.js'); require('bootstrap-webpack!./bootstrap.config.js');
var operationsTmpl = require('./operations/operations.html'); var operationsTmpl = require('./operations/operations.html');
var accountsTmpl = require('./accounts/accounts.html'); var accountsTmpl = require('./accounts/accounts.html');
var schedulerTmpl = require('./scheduler/scheduler.html'); var schedulerTmpl = require('./scheduler/scheduler.html');
var app = angular.module('accountant', [ angular.module('accountant', [
accountModule, accountModule,
loginModule, loginModule,
operationModule, operationModule,
schedulerModule, schedulerModule,
ngRoute, ngRoute,
]) ]).config(routing);
.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;