This is my angularjs code to create input text fields dynamically.
<form action="demo_form.asp" method="get">
//statically added textfields
value1:<input type="text" placeholder="Give inspection details. Eg. 10:00." ng-model="store.static1" required />
value2:<input type="text" placeholder="Give inspection details. Eg. 10:00." ng-model="store.static2" required />
//dynamically adding textfields
enter the number of new fields to be created:<input type="number" id="in_num" />
<button type="button" id="submit"> Create text fields </button>
<div id="dynamicInput" ></div></td>
//button to add values to the database
<button type="submit" ng-click="addValues($event)> add to database </button>
</form>
"ng-click="addValues($event)"" helps add these values to a mongodb database which i have already done.
javascript code used to make these fields is:
$(document).ready(function(e){
$('#submit').click(function(){
var inputIndex = $('#in_num').val();
for( var i=0; i<inputIndex; i++)
{
$('#dynamicInput').append('<input type=text id=id_'+ i +' style=width:100%; padding:12px 15px ng-model=store.value'+i+'/>');
}
});
});
On clicking the "add to database" button the values only from first and second textfields are geting added to the database but not the values added from the dynamically created textfields. Is there any way to do it?
ng-repeat!modelwill get set there!