angular++--简单版









tr:nth-child(odd){
background-color: red;
}
.tip{
color: red;
}






  • 编号:


  • 名称:


  • 数量:


  • 价格:


  • 地址:


  • 日期:



























编号 商品名称 数量 商品价格 地址 小计 日期 操作
{{x.id}} {{x.name}}

{{x.num}}

{{x.price}} {{x.product}} {{x.num*x.price}} {{x.date|date:”yyyy-MM-dd hh:mm:ss”}}



  • 编号:


  • 名称:


  • 数量:


  • 价格:


  • 地址:


  • 日期:



    <script type="text/javascript">
        var my = angular.module("myapp",[]);
        my.controller("ctrl",function($scope,$http){

            var update;
            $scope.mol = function(xid){
                $scope.ismolshow = true;
                for (var i = 0; i < $scope.shops.length; i++) {
                    if($scope.shops[i].id == xid){
                        update = $scope.shops[i];

                        $scope.aid = $scope.shops[i].id;
                        $scope.aname = $scope.shops[i].name;
                        $scope.anum = $scope.shops[i].num;
                        $scope.aprice = $scope.shops[i].price;
                        $scope.aproduct = $scope.shops[i].product;
                        $scope.adate = $scope.shops[i].date;
                    }
                }
            }

            $scope.update = function(){
                update.name = $scope.aname;
            }

            $scope.add = function(){
                var newtr = {};

                newtr.id = $scope.aid;
                newtr.name = $scope.aname;
                newtr.num = $scope.anum;
                newtr.price = $scope.aprice;
                newtr.product = $scope.aproduct;
                newtr.date = $scope.adate;

                if(newtr.id==""||newtr.id==null||newtr.id==undefined){
                    $("#tid").text("*编号不能为空");
                    return;
                }

                $scope.shops.push(newtr);
                $scope.isshow = false;
            }

            $scope.jian = function(obj,index){
                obj-=1;
                if(obj<0){
                    if(confirm("确定要删除吗")){
                        $scope.shops.splice(index,1);
                    }
                }else{
                    return obj;
                }
            }

            $scope.jia = function(obj){
                return obj+=1;
            }

            $http.get("aa.json").then(
                function success(response){
                    $scope.shops = response.data;
                }
            )
        });
    </script>
</body>

猜你喜欢

转载自blog.csdn.net/weixin_42791904/article/details/81275769