I am developing a "dynamic" form, where users choose the sequence, quantity, and which fields they will fill. Then I used ng-click to repeat the form's HTML code as follows:
The buttons: (There are 3 buttons, one for text, one video, another for the image, I copied only one to get cleaner.)
<div class="col-md-12 bloco_botoes" ng-controller="InformacoesObraController">
<a class="btn btn-default btn-lg" ng-model="item.texto" ng-click="adicionaTexto()">
Adicionar<br>TEXTO
</a>
</div>
My Controller:
function InformacoesObraController($scope) {
$scope.textos = [];
$scope.adicionaTexto = function() {
var elTexto = angular.element(
'<div class="input-group"><input id="nome_obra" name="texto" class="form-control" type="text-area" required=""></div>'
);
angular.element(document.querySelector('#forms-element')).append(elTexto);
};
};
Location where the HTML block is inserted:
<div class="col-md-12">
<br><br><div id="forms-element"></div>
</div>
The Problem:
When I send the information to the Bank I have problem because all fields have the least name ( name="text" ), so it only writes the first block. I am sending to a MongoDB Bank and I thought of converting the data into POST for JSON, hand did not work.
help me please! :)