Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
- </head>
- <body ng-app="myApp" ng-controller="todoCtrl">
- <h2>My Todo App</h2>
- <form ng-submit="todoAdd()">
- <input type="type" name="" ng-model="todoInput" placeholder="Add New">
- <input type="submit" name="Add New">
- </form>
- <br>
- <div ng-repeat="x in todoList">
- <input type="checkbox" ng-model="x.done"> <span ng-bind="x.todoText"></span>
- </div>
- <p><button ng-click="remove()">Remove</button></p>
- <button ng-click="annoy()">Annoy</button>
- <script type="text/javascript">
- var app = angular.module("myApp", []);
- app.controller("todoCtrl", function($scope){
- $scope.todoList = [{todoText: "Clean the House", done: false}, {todoText: "second object", done: false}];
- $scope.todoAdd = function(){
- $scope.todoList.push({todoText: $scope.todoInput, done: false});
- $scope.todoInput = "";
- }
- $scope.remove = function(){
- var oldList = $scope.todoList;
- $scope.todoList = [];
- angular.forEach(oldList, function(x){
- if(!x.done) $scope.todoList.push(x);
- })
- }
- $scope.annoy = function(){
- alert("annoy!")
- }
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement