Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 + Scala Play2?

I am somewhat new to the domain of web development. I am investigating Play2 and am trying to understand, do you need some kind of JS frontend framework to go with Play2 and Scala?

I notice that Play2 has a template engine, but it seems that it generates the HTML on the server and sends it to the browser. Does this mean that the need for a JS frontend like Angular2 is made irrelevant? Or is there still a reason to use Angular2 in a Play2 application? What instances would it make sense and why?

like image 702
rygo6 Avatar asked Feb 13 '16 09:02

rygo6


1 Answers

I have some experience of using Play 2 with AngularJS (currently rewriting frontend to Angular2).
I use Play 2 (scala) only for RESTful JSON backend, which is just great for this purpose and I use Angular for single page application frontend. I find this combination brilliant.

My project is hosted on GitHub, you can check it out here

There are three directories in the root:

  • restful with all backend stuff, written in scala, using Slick for DB, taking advantage of Play evolutions and all other stuff.
  • angularjs-client-deprecated with AngularJS code. I used angular-resource for making calls to backend.
  • client with Angular2 code. There is nothing there so far except for my experiments, however I've written a simple service for authentication with security token.

To summarise, I've been developing my project for almost 2 months so far, mainly to learn both Scala and AngularJS (now Angular2).

If you're planning to use JS framework for frontend, I would recommend you to use Play2 only for RESTFul Json backend. I don't see a reason to use Play2 html template engine in this case.

like image 118
Nico Avatar answered Oct 14 '22 10:10

Nico