You are on page 1of 2

Two files required (run Angular.

html file in browser)


1>Angular.html
2>index.js

Angular.js

<html ng-app = "simpleApp">


<head>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src = "index.js"></script>
</head>
<body>
<h2>AngularJS Form Submit Application</h2>
<div ng-controller = "simpleController">
<table border= 1>
<tr><th> No </th>
<th> Name </th>
<th> Age </th>
<th> City </th></tr>
<trng-repeat="entry in collection">
<td> {{$index+1}} </td>
<td> {{entry.name}}</td>
<td> {{entry.age}} </td>
<td> {{entry.city}} </td>
</tr>
</table>
<form ng-submit="addEntry()">
<h2> New Data Entry Form </h2>
<table>
<tr><td>Name:</td>
<td><input type="text" ng-model="newData.name" required></td>
</tr>
<tr><td>Age: </td>
<td><input type="number" ng-model="newData.age" required></td>
</tr>
<tr><td>city: </td>
<td><input type="text" ng-model="newData.city" required></td>
</tr>
<tr><td colspan=2><input type="submit" value="Add Entry"></td>
</td>
</table>
</form>
</div>
</body>
</html>
Index.js

var app=angular.module("simpleApp",[]);
app.controller("simpleController",function($scope)
{
$scope.collection=[
{name:"Amit",age:22,city:"Nashik"},
{name:"Neha",age:21,city:"Nashik"}];
$scope.addEntry=function()
{
$scope.collection.push($scope.newData);
$scope.newData='';
};
});

You might also like