-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenter_email.html
84 lines (72 loc) · 2.64 KB
/
enter_email.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script>
angular.module("MyApp", [])
.controller("MyController", function($scope) {
// Flags to control visibility of parts.
$scope.show_form = true;
$scope.show_table = false;
// Array to hold submitted form data.
$scope.entries = [];
$scope.submit = function () {
$scope.entries.push({
"timestamp" : Date(Date.now()).toString(),
"name" : $scope.name,
"email" : $scope.email
});
$scope.show_form = false;
$scope.show_table = true;
};
$scope.returnToForm = function () {
$scope.name = '';
$scope.email = '';
$scope.show_form = true;
$scope.show_table = false;
};
$scope.showCollectedEmails = function () {
if ($scope.entries.length > 0) {
$scope.show_table = true;
}
};
} );
</script>
<body ng-app="MyApp">
<div ng-controller="MyController">
<h3>Enter Email!</h3>
<form name="myForm" ng-submit="submit()" ng-show="show_form">
Name: <input type="text" name="name" ng-model="name" required />
<span class="error" ng-show="myForm.name.$error.required">
Required!
</span>
<br>
Email: <input type="email" name="email" ng-model="email" required />
<span class="error" ng-show="myForm.email.$error.required">
Required!
</span>
<span class="error" ng-show="myForm.email.$error.email">
This needs to be a valid email address!
</span>
<br>
<input type=submit id="submit" value="Submit"/>
<input type=button ng-click="showCollectedEmails()" value="Show Collected Emails"/>
</form>
<div ng-show="show_table">
<table>
<tr>
<th>Timestamp</th>
<th>Name</th>
<th>Email</th>
</tr>
<tr ng-repeat="entry in entries">
<td>{{entry.timestamp}}</td>
<td>{{entry.name}}</td>
<td>{{entry.email}}</td>
</tr>
</table>
<br>
<br>
<input type="button" ng-click="returnToForm()" value="Return To Entry Form"/>
</div>
</div><br>
</body>
</html>