Question

I am starting to develop a business spa application (mobile/desktop web app) with Play Framework 2 and AngularJS. Right now I am tending to go with following solution:

  • Play behaves as a RESTful application
  • Play also pre-processes partials
  • AngularJS handles the rest

My arguments for pre-processing partials are:

  • Play can remove parts of a partial for a more compact mobile view
  • Different user roles see more/less content of the partial
  • Correct language will be loaded into the partial

Are there any disadvantages with this approach? Do you think this would be the best solution for the project's requirements?

Was it helpful?

Solution

Server-side templating is usually what you want to get rid of when building an SPA. In general this should work, but there are a couple of disadvantages:

  • You are mixing two template languages, Play and AngularJS, so you must be careful not create an unmaintainable mess
  • Your display logic will also be distributed or duplicated between Angular and Play; in a pure RESTful approach Play would mostly be concerned about access control and JSON (input, output, validation)
  • You must create a route for every partial instead of just using the assets route
  • Server side templating slows down compilation speed
  • Returning different content depending on roles and desktop/mobile might mess with Angular's $template cache

Different user roles see more/less content of the partial

This should be handled by Angular IMHO, Play would just make sure to only serve the appropriate JSON to the right users.

Correct language will be loaded into the partial

How would you reuse Play's Lang in Angular? Build an inline variable? Again, just load it via JSON when the app bootstraps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top