Advertisement
Guest User

Untitled

a guest
May 27th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. angular.module('beerApp', [])
  2. .controller('beerCtrl', function($scope) {
  3. $scope.todos = [
  4. {text:'learn angular', done:true},
  5. {text:'build an angular app', done:false}];
  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. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement