-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
33 lines (25 loc) · 892 Bytes
/
app.js
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
'use strict';
(function(){
angular
.module('todoApp', ['ngMaterial'])
.controller('todoController', function($scope){
$scope.todos = [];
$scope.add = function(){
$scope.todos.push({ text: $scope.todoText });
$scope.todoText = '';
};
$scope.clear = function(){
$scope.todos.length = 0;
};
$scope.done = function(){
var count = 0;
angular.forEach($scope.todos, function(todo){
count += todo.done ? 1 : 0;
});
return count;
};
$scope.progress = function(){
return $scope.done() / $scope.todos.length * 100;
};
});
}());