2017-11-12 2 views
0

ich ein for:each wie diese haben js:Objekt aus thymeleaf Get

<tbody> 
    <tr th:each="bill : ${bills}" id="bill"> 
     <td th:text="${bill.bill_id}"></td> 
     <td th:text="${bill.client.phone}"></td> 
     <td th:text="${bill.date}"></td> 
     <td><a href="#" class="btn btn-info btn-xs" data-toggle="modal" id="open-modal">Ver detalles</a></td> 
    </tr> 
</tbody> 

Die Frage ist, wie kann ich die gesamte ${bill} auf eine Variable in js oder jquery bekommen, weil ich mehr Informationen benötigen, sah ich in der Dokumentation und es wird gesagt:

, aber ich habe versucht, diese auf einer externen js-Datei und nicht funktioniert, so brauche ich 1 Lösung.

imagen del error

Antwort

0

Sie ${bills} als Javascript-Objekt haben kann, versuchen Sie dies

<script th:inline="javascript"> 
/*<![CDATA[*/ 

    var bills = [[${bills}]]; //Make sure this is bills and not bill as you have done it. 
    console.log(bills); 

/*]]>*/ 
</script> 
+0

Bitte upvote und akzeptieren, wenn diese in irgendeiner Weise geholfen. Vielen Dank. –