fatlog fatlog - 4 months ago 20x
AngularJS Question

Play framework and Angular - Loading angular templates

I have an Angular app which I am serving from Play.
The main routes within Play all serve some HTML pages which contain ng-include statements to some angular templates which are in a "templates" folder in public...

<div ng-include="'@routes.Assets.versioned("templates/test.html")'"></div>

This works fine as I can use Play to reference the assets as normal. Now when the page loads in the browser, each of these templates load and in turn try to pull in further angular templates...

<div ng-include="'templates/test2.html'"></div>

But this results in a 404 as the "templates" folder cannot be resolved.
How can I have a truly public "templates" folder with Play where each of angular can pull in whatever templates it needs in the browser?



You will need something like this in your PLAY routes file:

GET /templates/*file controllers.Assets.at(path="/public/templates", file)