Good afternoon guys.
Next, I'm using AngularJS to add the details of a sale, however on the server side I'm using Spring MVC with JSTL making a forEach of the details to add on the server.
HTML that retrieves the details and scrolls through the elements:
<tr id='addr0' items ng-repeat="item in invoice.items">
<ec:inputText path="itens[${loop.index}].venda.oid" visible="false" />
<ec:inputText path="itens[${loop.index}].oid" visible="false" />
<c:forEach items="${venda.itens}" varStatus="loop">
<td><ec:inputSelect2 dataUrl="/cadastros/item"
onlyComp="true" dataText="descricao" dataId="oid"
path="itens[${loop.index}].item.oid" /></td>
<td><ec:inputText onlyComp="true"
id="venda.itens.quantidade[${loop.index}]" path="itens[${loop.index}].quantidade" /></td>
<td><ec:inputDecimal path="itens[${loop.index}].valorUnitario"
onlyComp="true" /></td>
<td><ec:inputDecimal path="itens[${loop.index}].valorTotal"
onlyComp="true" /></td>
<td><a href class='btn-delete pull-right btn btn-default'
ng:click='removeItem(${loop.index})'><spring:message
code='venda.deletar.item' /></a></td>
<tr id='addr${fn:length(venda.itens)}'/>
</c:forEach>
</tr>
HTML using AngularJS that generates the details and assigns the index to the Spring MVC and HTML elements:
<td><input ng-model='item.descricao' data-url='${pageContext.request.contextPath}/cadastros/item' data-id='oid' data-text='descricao' name='teste{{$index}}' id='teste{{$index}}' type='select2' name = 'itens[{{$index}}].produto.oid' style=' min-width: 150px;' class='form-control' /></td><td><input name = 'itens[{{$index}}].quantidade' ng-model='item.quantidade' type='text' class='form-control input-md'></td><td><input name = 'itens[{{$index}}].valorUnitario' type='text' ng-model='item.valorUnitario' class='form-control input-md'></td><td><input name = 'itens[{{$index}}].valorTotal' value='{{ item.quantidade * item.valorUnitario }}' type='text' readonly class='form-control input-md'></td><td><a href class='btn-delete pull-right btn btn-default' ng:click='removeItem($index)'><spring:message code='venda.deletar.item' /></a></td>
HTML is built normally, but when the user clicks on saving the information in the list, or rather, the detail, they do not go to the server, although the index is correct and I believe that this would not be good practice and would like to know the best solution you would give me. Preferably you do not need AJAX to save either the master or the details.
Necessarily everything built with AngularJS needs to be used by AngularJS tools to be sent to the server or can I let the JSP do the work? Do I have to use only one of the tools (JSTL or AngularJS) to handle the job?
Thank you in advance.