0
votes

I want to switch from play routing to angular routing so I would like to use angular ui router. I have a problem with how to use "templateUrl". I found this example which work on play 2.5 with dynamic routes:

# Dynamic part of the url
GET         /views/$template<.+>.html        controllers.ApplicationController.view(template)

so in play 2.4 I haven't this functionality and also I tried to put a link in templateUrl (which I define in my routes file) but it doesn't work

1

1 Answers

0
votes

It depends in which way you mean to use Play with Angular. The first option is to integrate angular stuff inside Play (like it is in the example you mentioned). According to the tutorial the route entry should be like this:

  GET    /*file    controllers.Assets.versioned(path="/public", file: Asset)

You should also follow the rest of directions of the tutorial.

Another approach is to develop Angular as a detached project. Play in this case is just a REST server. Integration between them is reached by locating all Angular stuff into the public folder and adding a static Play route. Play is not aware about Angular at all.

It should be like following:

  1. Put all angular files under the public folder of the Play project. Files may be organized in whatever directory structure.

  2. Create a static index.html somewhere under the public folder. This will be an entry point for the Angular stuff.

  3. Add the route to index.html into routes. In case index.html is directly in the public folder the route is like this:

    GET /       controllers.Assets.at(path="/public", file ="index.html")
    
  4. Add routing to the Angular files into the routes:

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

You can see some more details here.