I'm building an Express.js and Angular.js application. I'm noticing as I add views and controllers to Angular.js that I'm duplicating work. I'm actually declaring the route in two places. It doesn't seem very DRY.
Here I'm adding the route in Express:
app.get('/api/admin', admin.root(req, res));
And my Angular configuration:
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives']).
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider)
{
$routeProvider.when('/api/admin', {templateUrl: 'admin', controller: AdminCtrl});
$routeProvider.otherwise({redirectTo: '/'});
$locationProvider.html5Mode(true);
}
]);
My question is, is there any way to not have to declare each route in the angular.module function? Maybe automatically generate this?