路由,删除,模糊查询,查询天气,全选,添加

来源:互联网 发布:color软件下载安装 编辑:程序博客网 时间:2024/06/16 04:14
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style>        *{            margin:0;            padding:0;        }        li{            list-style: none;        }        .left{            float: left;        }        .left li{            border:1px solid black;            height: 35px;            width: 100px;            line-height: 25px;            text-align: center;            color: black;        }        .inner{            padding-left: 50px;            float: left;        }        .tb1{            margin-top: 10px;            border-collapse: collapse;        }        .tb1 td{            width: 150px;            height: 40px;            line-height: 40px;            border: 1px solid black;        }        .tb1 th{            width: 150px;            height: 40px;            line-height: 40px;            border: 1px solid black;        }        header{            height:100%;            height: 50px;            line-height: 50px;            text-align: center;            background: pink;        }    </style>    <script src="../test1/angular.min.js"></script>    <script src="../test1/angular-route.js"></script>    <script>        var myapp=angular.module("myapp",["ngRoute"]);        myapp.config(function ($routeProvider) {            $routeProvider.when("/home",{                templateUrl:"pages/home.html",                controller:"homeCtrl"            }).when("/second",{                templateUrl:"pages/second.html",                controller:"secondCtrl"            }).when("/third",{                templateUrl:"pages/third.html",                controller:"thirdCtrl"            })        })        myapp.controller("homeCtrl",function ($scope) {            $scope.date=[{                bianhao:"123",name:"iphone",price:3400,num:10            },{                bianhao:"321",name:"ipad",price:6400,num:100            },{                bianhao:"512",name:"plus",price:5900,num:1000            },{                bianhao:"2144",name:"sumsung",price:1000,num:1            }]            $scope.delete=function (index) {                var a = confirm("确定删除吗?");                if(a){                    $scope.date.splice(index,1);                }            }         $scope.ischeck=false;            $scope.checkAll=function () {                $scope.ischeck=!$scope.ischeck;            }            $scope.deleteall=function () {                var a = confirm("确定全部删除吗?");                if(a){                    $scope.date.splice(0,$scope.date.length);                }            }            $scope.sort="name";            $scope.servece=false;            $scope.sortFun=function (column) {                if($scope.sort==column){                    $scope.servece=!$scope.servece;                }                $scope.sort=column;            }        })       //查询天气        var u1="https://free-api.heweather.com/v5/weather?city=";        var u2;        var u3="&key=545d63e185fc48169a43cbabba6e74d2";        myapp.controller("secondCtrl",function ($scope,$http) {            $scope.city="beijing";            $scope.show=false;            $scope.search=function () {                u2=$scope.city;                $scope.show=true;                $http({                    url:u1+u2+u3,                }).then(function (data) {                    $scope.cityname=data.data.HeWeather5[0].basic.city;                    $scope.weather=data.data.HeWeather5[0].daily_forecast[0].cond.txt_d;                    $scope.wendu=data.data.HeWeather5[0].daily_forecast[0].hum;                });                $scope.city="";            }        })        //向表格中添加数据        myapp.controller("thirdCtrl",function ($scope) {            $scope.arr=[];            $scope.add=function () {                $scope.arr.push({name:$scope.name,num:$scope.num,price:$scope.price,where:$scope.where});                $scope.name="";                $scope.num="";                $scope.price="";                $scope.where="";            }            //删除数据            $scope.delete=function (index) {                $scope.arr.splice(index,1);            }        })    </script></head><body ng-app="myapp"><header>xxx管理系统</header><ul class="left">    <li><a href="#home">首页</a></li>    <li><a href="#second">第二</a></li>    <li><a href="#third">第三</a></li></ul><div ng-view="" class="inner"></div></body></html>
原创粉丝点击