I am realizing a project using AngularJS for the front end, and Grails for the backend.
- Angular JS => Single page application
- Grails => REST API to be used in the WebApp itself and 3rd party apps.
This is how I setup the project:
web-app
|
|_____ js ( angular controllers, modules, partial templates.)
|
|_____ images
|
|_____ css
grails-app
|
|_____ views ( in here I have my main view, the one I use at the first user request )
Rather than using the Resources Plugin, I prefer building my own front end with Grunt, and then I only link the final files inside the layout itself.
I structured the js
folder in web-app to contain a partials
folder with all the partial templates to be called within AngularJS
This is my pretty standard angular code to load the views:
angular.module('myapp', []).
config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/invoices', {
templateUrl: 'partials/invoices-list.html',
controller: InvoiceListCtrl
})
.when('/invoices/:invoiceId', {
templateUrl: 'partials/invoice-details.html',
controller: InvoiceDetailCtrl}
)
.otherwise({redirectTo: '/dashboard'}, {
templateUrl: 'partials/dashboard.html',
controller: DashboardCtrl
});
}]);
What happens is that Angular is unable to get those partial templates, since the partial folder is not copied in the tomcat work
directory.
I don't know which other approach can be used for a Grails powered project.