This is a Grails plugin that allows you to use Angular.js based scaffolding.
After installing the plugin run:
This will install the Angular JS scaffolding templates into your project under
src/templates/scaffolding. It will also copy some common HTML template files that will be shared by all scaffolded views into
To generate the controller and views for a domain class run:
grails ng-generate-all _domain class name_
Dynamic scaffolding is only supported for the controller. Currently you will need to generate the views for each domain class.
To generate only the views and use a dynamically scaffolded controller run:
grails ng-generate-views _domain class name_
How it works
Each 'page' in the CRUD interface for a particular domain class is accessed using a URL fragment;
#/create, etc. The page content is rendered by Angular JS using an HTML template and the data to populate the page is retrieved from the controller using an AJAX call.
Enable optimistic locking check
By default, the JSON converter does not send the object's "version" field generated by Hibernate. Because of that, the controller does not check when concurrent modifications occur. To enable optimistic locking check, simply add the following in your Config.groovy:
grails.converters.json.domain.include.version = true
Using Grails RESTful URL mappings
By default Grails uses a non-RESTful URL scheme where the controller action representing the verb is part of the URL. In the Grails documentation there is a section on configuring RESTful URL mappings. If you want to use such a URL scheme with this plugin you will need to override the
web-app/js/grails-default.js file that configures an Angular $resource service that maps to your Grails controllers.
This is an experimental work-in-progress. See the issues list for outstanding features.
There is a demo of this plugin running on Cloud Foundry.
The demo application is also included under
test/apps/grails-ng in this project.
There are some end-to-end tests that use Casper JS. To run the tests:
cd test/apps/grails-ng grails run-app
Then in another terminal:
casperjs test --includes=test/casper/includes/casper-angular.coffee test/casper/specs/