Skip to content

Instantly share code, notes, and snippets.

@mdonkers
Last active December 17, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdonkers/5668300 to your computer and use it in GitHub Desktop.
Save mdonkers/5668300 to your computer and use it in GitHub Desktop.
Provided combination of 'routes' and Application does not seem to work. Problem loading Angular JavaScript, the commented line (fetching from googleapis) works, but the routes.Assets include does not work. Results in syntax error on '<'
object Application extends Controller {
def index(path: String) = Action {
Ok(views.html.main())
}
}
@()
<!DOCTYPE html>
<html ng-app>
<head>
<title>Pissalot Application</title>
<meta charset="utf-8" />
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
@*<script src="@routes.Assets.at("javascripts/jquery-1.9.0.min.js")" type="text/javascript"></script>*@
@*<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>*@
<script src="@routes.Assets.at("javascripts/angular.min.js")"></script>
</head>
<body>
<div>
<label>Name:</label>
<input type="text" ng-model="yourName" placeholder="Enter a name here">
<hr>
<h1>Hello {{yourName}}!</h1>
</div>
</body>
</html>
GET /assets/*file controllers.Assets.at(path="/public", file)
GET / controllers.Application.index(path = "")
GET /*path controllers.Application.index(path)
@mdonkers
Copy link
Author

Make sure to put the path matching with '*' wildcard last, gave strange errors...

@sandermak
Copy link

I think your second line in the routes catches all URLs and passes them to your index method. Have you tried adding something like:

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

to the routes file, and load your JS with /assets/javascripts/etc... ? You should put it at the top of your current routes, otherwise the catch-all route kicks in before the Assets controller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment