I have a from which contains two text boxes one for getting name and other for email and there a button to add new row which add these two textboxes I'm trying to get all the values of Name and Email through AngularJS but I am new to Angular
Here is my code:
JS CODE
function addrow() {
var table = document.getElementById("emp");
var row = table.insertRow(2);
var name = row.insertCell(0);
var email = row.insertCell(1);
name.innerHTML = "<input id='Name' type='text' value='' name='ename' ng-model='data.ename'>";
email.innerHTML = "<input type='text' value='' name='Email' id='email' ng-model='data.email'>";
}
HTML
<form name="employees" ng-submit="emp()">
<table id="emp">
<tr>
<td>Employee Name
</td>
<td>Employee Email
</td>
</tr>
<tr>
<td>
<input type="text" id="Name" name="ename" ng-model="data.ename" />
</td>
<td>
<input type="email" id="email" name="email" ng-model="data.email" />
</td>
</tr>
</table>
<button class="btn btn-primary" onclick="addrow();">Add new</button>
<input type="submit" class="btn" />
</form>
AngularJS CODE
var model1Controller = ["$scope", "$http", function ($scope, $http) {
$scope.data = [];
$scope.emp = function () {
alert($scope.data.ename);
}
}]