Skip to content

Commit

Permalink
Add controllers relative path (#66)
Browse files Browse the repository at this point in the history
This can be used to group common controllers into folders, like
'students', 'admins', or 'courses
  • Loading branch information
MatiasComercio authored Jan 30, 2017
1 parent 9c9fd70 commit 452a96f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function (grunt) { // eslint-disable-line strict
https: false,
changeOrigin: true,
rewrite: {
'^/api/v1': '/grupo1/api/v1'
'^/api/v1': '/grupo1-stage/api/v1'
}
}
]
Expand Down
9 changes: 8 additions & 1 deletion app/scripts/paw.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ define(['routes',

if (config.routes !== undefined) {
angular.forEach(config.routes, function(route, path) {
$routeProvider.when(path, {templateUrl: route.templateUrl, resolve: dependencyResolverFor(['controllers/' + route.controller]), controller: route.controller, gaPageTitle: route.gaPageTitle});
$routeProvider.when(path, {
templateUrl: route.templateUrl,
resolve: dependencyResolverFor(
['controllers' + (route.relativePath || '') + '/' + route.controller]
),
controller: route.controller,
gaPageTitle: route.gaPageTitle
});
});
}
if (config.defaultRoutePath !== undefined) {
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ define([], function() {
},
'/students': {
templateUrl: 'views/students/index.html',
controller: 'StudentsIndexCtrl'
controller: 'StudentsIndexCtrl',
relativePath: '/students'
}
/* ===== yeoman hook ===== */
/* Do not remove these commented lines! Needed for auto-generation */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

define(['paw',
'angular-mocks',
'controllers/StudentsIndexCtrl'],
'controllers/students/StudentsIndexCtrl'],
function() {
describe('Students Index Ctrl', function() {
beforeEach(module('paw'));
Expand Down

0 comments on commit 452a96f

Please sign in to comment.