什么是todolist"text-align: center">
功能:
首先,所有的数据都是存储在localStorage中的;其次,文本框中输入内容后,回车即可添加任务主题;可以按内容和添加时间来排序任务;可以筛选任务,分为未完成和已完成;可以一键删除所有任务;在任务清单前打勾,即表示为已完成;点击任务后面的x则会删除这一条任务;双击任务进入任务编辑模式;在大文本框中填写详细的任务计划;
(只能在全部任务列表中勾选该任务是否完成哦 0.0...)
直接上代码啦(注释应该写的很清楚哦)
<div class="container" ng-app="taskList"> <div ng-controller="TaskController"> <h1>My Task List</h1> <form ng-submit="addTask()"> <input type="text" class="form-control" ng-model="taskText" autofocus="autofocus" required="required" placeholder="What needs to be done" /> <div class="checkbox" ng-show="hasTask()"> <label> <input type="checkbox" ng-model="isAllDone" ng-click="allDone()" /> 标记所有为以解决 </label> </div> </form> <div class="btn-toolbar" ng-show="hasTask()"> <div class="btn-group"> <button type="button" class="btn btn-success" ng-click="predicate='text'; reverse=!reverse">内容</button> <button type="button" class="btn btn-success" ng-click="predicate='time'; reverse=!reverse">时间</button> </div> <div class="btn-group" role="group"> <button type="button" class="btn btn-warning" ng-click="query.done=false">未完成</button> <button type="button" class="btn btn-warning" ng-click="query.done=true">已完成</button> <button type="button" class="btn btn-warning" ng-click="query.done=''">全部</button> </div> <div class="btn-group"> <button type="button" class="btn btn-primary all">全部展开</button> </div> <div class="btn-group"> <button type="button" class="btn btn-danger" ng-click="removeAll()">删除所有任务</button> </div> </div> <ul class="taskList"> <li ng-repeat="task in taskList | filter:query | orderBy:predicate:reverse"> <div class="checkbox"> <label> <input type="checkbox" ng-model="task.done" ng-click="save()"><span class="text done-{{task.done}}">{{task.text}}</span> </label> <button type="button" class="close" ng-click="removeTask(task)" data-dismiss="alert">×</button> <span class="pull-right time">{{task.time}}</span> </div> <div class="taskText"> <form> <textarea ng-model="task.desc" class="form-control desc" rows="4" cols="73" required="required"></textarea> <button ng-click="addDesc(task)" class="btn btn-primary btn-sm submit" type="submit">submit</button> </form> </div> </li> </ul> <div class="count"> 未完成:<span class="badge">{{count()}}</span> 已完成:<span class="badge">{{countDone()}}</span> 总数:<span class="badge">{{taskList.length}}</span> </div> </div> </div>
下面是js代码:
var app = angular.module('taskList',[]); app.controller('TaskController',function($scope , dateFilter){ //获取缓存中的taskList数据 var tmp = localStorage.getItem('taskList'); //转为json数据进行操作 $scope.taskList = tmp "yyyy-MM-dd HH:mm:ss"); } $scope.hasTask = function(){ return $scope.taskList.length > 0; } //标记为全部完成 $scope.allDone = function(){ angular.forEach($scope.taskList , function(task){ task.done = $scope.isAllDone; }); $scope.save(); } //统计已完成的任务 $scope.countDone = function(){ var count = 0; angular.forEach($scope.taskList , function(task){ count += task.done ".taskList").delegate('li','dblclick',function(){ $(this).find('.taskText').slideToggle(); }); //全部展开或全部收起 $('.all').click(function(){ var _this = $(this); if(_this.text() == '全部展开'){ $('.taskText').slideDown(); _this.text('全部收起'); }else{ $('.taskText').slideUp(); _this.text('全部展开'); } }); //确认修改描述框后隐藏 $('.taskList').delegate('.submit','click',function(){ var _this = $(this); $(this).click(function(){ _this.parents('.taskText').slideUp(); }); }); //描述框获得焦点又失去焦点后会自动隐藏 $('.taskList').delegate('.desc','focus',function(){ var _this = $(this); _this.blur(function(){ _this.parents('.taskText').slideUp(); }); }); });
到这就大功告成啦, 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。