Shashank.gupta40
Shashank.gupta40

Reputation: 945

How to use AngularJs in Grails application along with MySql databse

I need to use AngularJs in Grails application along with MySql database,

I have searched plugins provided by Grails but unable to do so because of lack of plugin documentations and searched the web also but hard luck.

I have searched web also but not worked at all. Unable to find a single tutorial for Grails to use AngularJs with templates.

Please help me in accomplishing my task by providing vision on how to use AngularJs in Grails

or by providing a link of the demo-app or tutorial.

Upvotes: 2

Views: 1492

Answers (2)

Jagadeesh
Jagadeesh

Reputation: 570

I have done demo application using grails and angularjs. User login, signup, creating editing deleting contacts. I created this front end using angularjs similar structure to grails mvc pattern. Contact Module

1. Grails  -> URLMappings,
   Angular -> Routing (app.js)
2. Grails  -> ContactController(Actions:create,list,edit,delete,details) 
   Angular -> ContactController(Actions: create,list,edit,delete,details)
3. Grails  -> ContactService(Methods: create,save,edit,delete,details) 
   Angular -> ContactService(Functions: create,save,edit,delete,details)
4. Views   -> All views are created using Angularjs (Create, Details)

I went through lot of tutorials and did this app to match with Grails MVC Pattern so any one can understand this angular demo app if they are having little knowledge on Grails

Demo : http://jagadeesh-manne.rhcloud.com/

Source : http://mannejkumar.github.io/GrailsAngularDemoApp/

Upvotes: 2

Brian Genisio
Brian Genisio

Reputation: 48167

Angular.js is a client-side library and is not (and should not be) coupled to the server technology.

In your Grails application, you will want to create REST services for your Angular.js code to talk with. Your JavaScript will either use $http or $resource` to talk with the REST api you generate using Grails.

The fact that you are using MySQL should be completely abstracted away from your Angular code. When you write your REST controllers, they will talk to the database for you via the models and return JSON.

Then, you just include Angular.js in your HTML output and write JavaScript the way you normally would.

Upvotes: 1

Related Questions