forked from rajeshwerkushwaha/ngapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.html
38 lines (36 loc) · 1.18 KB
/
events.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
<!DOCTYPE HTML>
<html ng-app>
<head>
<title>Hello</title>
</head>
<body>
<div ng-controller="eventController">
<label>Total Event: {{events.length}}</label><br>
<label>Remaining Event: {{remaining()}}</label>
<ul class="unstyled">
<li ng-repeat="event in events">
<input type="checkbox" ng-model="event.done">{{ event.name }}
</li>
</ul>
<input type="text" ng-model="newEvent" placeholder="Enter event name">
<button ng-click="addEvent()">Add Event</button>
</div>
<hr>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.7/angular.min.js"></script>
<script type="text/javascript">
function eventController($scope){
$scope.events = [{'name':'Event 1', 'done': false}, {'name':'Event 2', 'done': false}, {'name':'Event 3', 'done': false}];
$scope.addEvent = function(){
$scope.events.push({'name':$scope.newEvent, 'done': false});
}
$scope.remaining = function() {
var count = 0;
angular.forEach($scope.events, function(event) {
count += event.done ? 0 : 1;
});
return count;
};
}
</script>
</body>
</html>