Suppose I have a RESTful web server. I would like to load dynamic HTML based on the request.
If the browser sends an HTTP GET request for /user/123
, I would like to load an HTML page that is customized for User #123, which I have data on back in my database.
So for example, if User #123 had the name "Foo" in my DB, I would like to render an HTML page saying "Hello, Foo!".
How would I do this? The front-end is AngularJS, and back-end is Scala.
The Scala back-end can retrieve the Name of User #123 front the DB. But I don't know how to send this information back to the browser, since I don't know of a way to embed code in the HTML like you could in PHP.
This is a pretty fundamental use case scenario for AngularJS. You load the variable from the Scala server, formatted as JSON, as the response to an AngularJS GET request. Then you take the response to that (see docs for Angular $http.get), map it to something in the applicable AngularJS controller's scope, and then interpolate it:
<div ng-controller="whateverController">
{{ user.name }}
</div>
As for how you generally run a web server in Scala...that's even more vague than the rest of your question.