coreWebApp.modules.<%= module %> = angular.module('<%= module %>Module', []);

<% for controller, path in controllers %>
coreWebApp.modules.<%= module %>.controller('<%= module ~ controller|capitalize %>Controller', <% include path %>);
<% endfor %>

coreWebApp.modules.<%= module %>.config(['$stateProvider', function($stateProvider) {
console.log('loading <%= module %> module');
    $stateProvider
    	.state('<%= module %>', {
            abstract: true,
            url: '<%= path({module: module}, "admin") %>',
            template: '<span ui-view></span>',
            // resolve : coreWebApp.resolvables
        })
        <% for controller, code in controllers %>.state('<%= module %>.<%= controller %>', {
        	url: '<%= controller %>/<% if controller in ['edit', 'delete'] %>:id/<% endif %>',
            templateUrl : '<%= url({"module": "admin", "ngmodule": module, "resource": 'partials/'~ controller ~'.html'}, 'angular_resource') %>',
            controller  : '<%= module ~ controller|capitalize %>Controller',
            resolve : coreWebApp.resolvables,
            reloadOnSearch : false,
            data: {
                authorizedRole: '<%= module %>:<%= controller %>'
            }
        })<% endfor %>;
}]);

<% if advanced_search %>
coreWebApp.modules.<%= module %>.run(['AdvancedSearch', function(AdvancedSearch) {
	AdvancedSearch.addModule('<%= module %>', '<%= url({"module": "admin", "ngmodule": module, "resource": 'partials/search.html'}, 'angular_resource') %>');
}]);
<% endif %>