-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommentbox.html
79 lines (78 loc) · 2.56 KB
/
commentbox.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Comment Box</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="commentbox.js"></script>
<style>
html,body{
width: 100%;
}
.form-division{
margin: auto 30%;
}
input,textarea{
width: 250px;
margin: 1em 5em;
}
input{
height: 30px;
}
ul li{
padding: 10px;
list-style-type: none;
color: #006bb3;
border-bottom: 1px solid #006bb3;
}
input[type=submit]{
color: #fff;
background-color: #006bb3;
border: 0px;
}
</style>
</head>
<body ng-app="myApp" ng-controller="myctrl">
<div class="form-division">
<h1>Comment Box</h1>
<form ng-submit="comments(form)" name="commentForm" novalidate>
<table>
<tr>
<td>
<label>User Name:</label>
</td>
<td>
<input type="text" ng-model="form.username" name="user" required>
<span style = "color:red" ng-show="commentForm.user.$invalid && commentForm.user.$touched">Name is required</span>
</td>
</tr>
<tr>
<td>
<label>Your Comment:</label>
</td>
<td>
<textarea rows="5" ng-model="form.comment" name="comment" required>
</textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit"value="Post Comment" ng-disabled="commentForm.user.$invalid">
</td>
</tr>
</table>
</form>
<h2>Comments:</h2>
<ul>
<li ng-repeat="item in comment">
<p><b>User :</b> {{item.username}}</p>
<p><b>Comment :</b> {{item.comment}}</p>
</li>
</ul>
</div>
</body>
</html>