日程表

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../angular-1.5.5/angular.min.js"></script>
    <script>
        //模拟数据
        var data = {
            user:"李四",
            items:[
                {action:"约刘诗诗吃饭",done:false},
                {action:"约刘诗诗跳舞",done:false},
                {action:"约刘诗诗敲代码",done:true},
                {action:"约刘诗诗爬长城",done:false},
                {action:"约刘诗诗逛天坛",done:false},
                {action:"约刘诗诗看电影",done:false}
            ]
        };
        var myapp=angular.module("myapp",[]);
        myapp.filter("todo",function(){
            return function(a,flag){
                var arr=[];
                for(var i=0;i<a.length;i++){
                    if(a[i].done==false){
                        arr.push(a[i])
                    }else{
                        if(flag==true){
                            arr.push(a[i])
                        }
                    }
                }
                return arr;
            }
        });
        myapp.controller("myCtrl",function($scope){
            $scope.data=data;
            $scope.complate=false;
            //计算数;两
            $scope.count=function(){
                var n=0;
                for(var i=0;i<$scope.data.items.length;i++){
                    if($scope.data.items[i].done==false){
                        n++;
                    }
                }
                return n;
            };
            //
            $scope.addItem=function(){
                $scope.data.items.push({'action':$scope.add,'done':false});
            }
        })
    </script>
</head>
<body ng-app="myapp" ng-controller="myCtrl">
<h1>{{data.user}}的日程表<span>{{count()}}</span></h1>
<input type="text" ng-model="add"><button ng-click="addItem()">添加</button>
<table>
    <thead>
    <tr>
        <th>序号</th>
        <th>日程</th>
        <th>完成</th>
    </tr>
    </thead>
    <tbody>
    <tr ng-repeat="item in data.items|todo:complate">
        <td>{{$index}}</td>
        <td>{{item.action}}</td>
        <td><input type="checkbox" ng-model="item.done"></td>
    </tr>
    </tbody>
</table>
<div>显示全部<span><input type="checkbox" ng-model="complate"></span></div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值