1

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.

Blank Bear
  • 59
  • 1
  • 9
  • 3
    Your mixing up something here. From your code I'm guessing you mean AngularJS and not Ajax. Ajax is a pattern of communication between client and server. AngularJS is a client side ui library which you are using for databinding here. It has nothing to do with the play framework. You will have to send the data from the client to the server via an HTTP request. Your question indicates that you need to gain some basic knowledge and it won't help to answer your question. Maybe you should read the Play documentation or better some general introduction into web development before continuing. – Martin Ring Apr 28 '14 at 11:50

1 Answers1

0

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)
Community
  • 1
  • 1
biesior
  • 55,576
  • 10
  • 125
  • 182