Is there a way to use Play routing in scala js fil

2019-07-19 01:48发布

I use Play! Scala 2.4 with scala js, and I would like to know if there is a way to get the routing config file from the scala js files.

It would be very convenient since it would allow me to replace urls as string by something like application.routes.Application.admin().

Do you know any workaround to do this?

2条回答
一纸荒年 Trace。
2楼-- · 2019-07-19 02:14

Supporting the previous answer, you can take a look at my code for a rather complex real-world example.

The JavaScript side

The Scala.js facade around that

查看更多
姐就是有狂的资本
3楼-- · 2019-07-19 02:28

You can use javascript reverse routing. It will help you to define routes from your js code. It will look like this:

@helper.javascriptRouter("jsRoutes")(
  routes.javascript.Application.admin
)
...
<script>
   console.log(jsRoutes.routes.Application.admin())
</script>
查看更多
登录 后发表回答