문제

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.

도움이 되었습니까?

해결책

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top