Question

how can i convert the variables in ajax.

 <li ng-repeat="item in newsItems | filter:q" style="background-color: white;">
      {{item}}</br>

{{item}} displays data in the browser. but i want to transfer this item data to the scala side. the one with the @, because i need the item in:

 @form(routes.Application.newItem({{item}})){....}

whenever i run this. it displays.

 item not found.

what i want is a step or anything to convert this ajax data to the scala side variable.

Was it helpful?

Solution

You can't do that directly, keep in mind that JavaScript is client-side technology and Scala template is backend one. That means that Play compiles the view long, long before the client (and its JS) will see it.

You have 2 solutions:

  1. Replace action attribute of form tag using JavaScript
  2. You can also use Play's JavaScript routes to create url (also using javascript after page rendering)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top