0
I am developing a "dynamic" form, where users choose the sequence, quantity and which fields to fill. Then I used ng-click to repeat the HTML code of the form as follows below:
the buttons: (There are 3 buttons, one for text, a video, another for image, I copied only one to be 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"), then just record the first block. I am sending to a Mongodb Bank and thought of converting the data in the POST to JSON, hand did not work.
help me Please! :)
@Souzaxavier I believe you will have to send this data in a collection of "texts".
– Fabio Silva Lima
@Fabiosilvalima in what way? Because it is already being saved a collection. But with feathers an item.
– Sousa Xavier
Too bad now I can’t help you, tomorrow I see this parade
– Fabio Silva Lima
As I understand it, Voce needs to add an index example: ng-model="item.text[$index]" This index should be added at each click. So in the click add it should scroll through the text list.
– Junior Porfirio
I will try to implement this index. Thank you! @Juniorporpirio
– Sousa Xavier