Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
  7. </head>
  8. <body ng-app="myApp" ng-controller="todoCtrl">
  9. <h2>My Todo App</h2>
  10.  
  11. <form ng-submit="todoAdd()">
  12. <input type="type" name="" ng-model="todoInput" placeholder="Add New">
  13. <input type="submit" name="Add New">
  14. </form>
  15. <br>
  16.  
  17. <div ng-repeat="x in todoList">
  18. <input type="checkbox" ng-model="x.done"> <span ng-bind="x.todoText"></span>
  19. </div>
  20.  
  21. <p><button ng-click="remove()">Remove</button></p>
  22. <button ng-click="annoy()">Annoy</button>
  23.  
  24.  
  25.  
  26.  
  27.  
  28. <script type="text/javascript">
  29. var app = angular.module("myApp", []);
  30. app.controller("todoCtrl", function($scope){
  31. $scope.todoList = [{todoText: "Clean the House", done: false}, {todoText: "second object", done: false}];
  32. $scope.todoAdd = function(){
  33. $scope.todoList.push({todoText: $scope.todoInput, done: false});
  34. $scope.todoInput = "";
  35. }
  36. $scope.remove = function(){
  37. var oldList = $scope.todoList;
  38. $scope.todoList = [];
  39. angular.forEach(oldList, function(x){
  40. if(!x.done) $scope.todoList.push(x);
  41. })
  42. }
  43. $scope.annoy = function(){
  44. alert("annoy!")
  45. }
  46. });
  47. </script>
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement