Another example from the manpage
file: code/todo.js
1: function TodoCtrl($scope) {
2: $scope.todos = [
3: {text:'learn angular', done:true},
4: {text:'build an angular app', done:false}
5: ];
6:
7: $scope.addTodo = function() {
8: $scope.todos.push({text:$scope.todoText, done:false});
9: $scope.todoText = '';
10: };
11:
12: $scope.remaining = function() {
13: var count = 0;
14: angular.forEach($scope.todos, function(todo) {
15: count += todo.done ? 0 : 1;
16: });
17: return count;
18: };
19:
20: $scope.archive = function() {
21: var oldTodos = $scope.todos;
22: $scope.todos = [];
23: angular.forEach(oldTodos, function(todo) {
24: if (!todo.done) $scope.todos.push(todo);
25: });
26: };
27: }