<!doctype html><htmlng-app="todoApp"><head><metacharset="utf-8"><scriptsrc="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script><script>angular.module('todoApp',[]).controller('TodoListController',function(){vartodoList=this;todoList.todos=[];todoList.addTodo=function(){todoList.todos.push({text:todoList.todoText,done:false});todoList.todoText='';};todoList.remaining=function(){varcount=0;angular.forEach(todoList.todos,function(todo){count+=todo.done?0:1;});returncount;};todoList.archive=function(){varoldTodos=todoList.todos;todoList.todos=[];angular.forEach(oldTodos,function(todo){if(!todo.done)todoList.todos.push(todo);});};});</script></head><body><h2>Todo</h2><divng-controller="TodoListController as todoList"><span>{{todoList.todos.length}}個中、{{todoList.remaining()}}個のTODOが残っています。</span> [ <ahref=""ng-click="todoList.archive()">アーカイブ</a> ]
<ulclass="unstyled"><ling-repeat="todo in todoList.todos"><inputtype="checkbox"ng-model="todo.done"><spanclass="done-{{todo.done}}">{{todo.text}}</span></li></ul><formng-submit="todoList.addTodo()"><inputtype="text"ng-model="todoList.todoText"size="30"placeholder="新しいTODO"><inputclass="btn-primary"type="submit"value="追加"></form></div></body></html>
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.