How to assign or initialize a Java array to Javascript array, without using JSP? -
i working in play framework , need use java array inside javascript.
i tried following -
var jsarray = ${javaarray};
where javaarray
array in java controller, being rendered html view.
but, not working. can please me on this?
don't forget you're not passing variables... you're writing javascript code
so, have make array rendering nicely javascript
var jsarray = [%{javaarray.eachwithindex{it,idx-> }% ${it}${(idx<javaarray.size()-1)?",":""} %{ } }%]
use fits template engine. have iterate through array prints out values on view
ps : i've used groovy notation...
Comments
Post a Comment