<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .color{ color: red; } .bo{ float: left; padding: 20px; } </style> <script src="../test29/angular.min.js"></script> <script src="../test29/angular-route.js"></script> <script> var myapp = angular.module("myapp",["ngRoute"]); myapp.config(function ($routeProvider) { $routeProvider.when("/one",{ templateUrl:"pages/one.html", controller:"oneCtrl" }).when("/two",{ templateUrl:"pages/two.html", controller:"twoCtrl" }).when("/three",{ templateUrl:"pages/three.html", controller:"threeCtrl" }).when("/richeng",{ templateUrl:"pages/richeng.html", controller:"richengCtrl" }).when("/home",{ templateUrl:"pages/home.html", controller:"homeCtrl" }) }) myapp.controller("oneCtrl",function ($scope) { $scope.date=[{ id:'1235',name:'iphone',price:3400,num:10,check:false },{ id:'425',name:'ipad',price:6400,num:500,check:false },{ id:'235',name:'mini',price:2400,num:100,check:false },{ id:'8635',name:'sumsung',price:100,num:1,check:false }] $scope.checkall=function () { for(var i=0;i<$scope.date.length;i++){ $scope.date[i].check=!$scope.date[i].check; } } $scope.delete=function (index) { var b = confirm("确定删除吗?"); if(b){ $scope.date.splice(index,1); } } $scope.deleteall=function () { var a=confirm("确定要删除吗?"); if(a){ for(var i=$scope.date.length-1;i>=0;i--){ if($scope.date[i].check==true){ $scope.date.splice(i,1); } } } } $scope.sort="name"; $scope.reve=false; $scope.sortFun=function (column) { if($scope.sort==column){ $scope.reve=!$scope.reve; } $scope.sort=column; } $scope.class1=function (name) { if(name==$scope.sort){ return 'color'; } } //修改密码 $scope.arr=[]; $scope.addbuy=function (index) { for(var i =0;i<$scope.date.length;i++){ if($scope.date[i].id==index){ $scope.arr.push({id:$scope.date[i].id, name:$scope.date[i].name, price:$scope.date[i].price, num:1}); } } }; $scope.buycardel=function (index) { $scope.arr.splice(index,1); } $scope.allmoney=function () { $scope.money=0; for(var i=0;i<$scope.arr.length;i++){ $scope.money+=$scope.arr[i].price*$scope.arr[i].num; } } $scope.add1=function (index) { $scope.arr[index].num++; } $scope.jian1=function (index) { $scope.arr[index].num--; } }) var u1="https://free-api.heweather.com/v5/weather?city="; var u2; var u3="&key=545d63e185fc48169a43cbabba6e74d2"; myapp.controller("twoCtrl",function ($scope,$http) { $scope.city="beijing"; $scope.ask=function () { u2=$scope.city; $http({ url:u1+u2+u3, }).then(function (data) { $scope.cityname=data.data.HeWeather5[0].basic.city; $scope.cityweather=data.data.HeWeather5[0].daily_forecast[0].cond.txt_d; $scope.citywendu=data.data.HeWeather5[0].daily_forecast[0].hum; }) $scope.city=""; } }) myapp.controller("threeCtrl",function ($scope) { $scope.cheke=function () { $scope.differ=$scope.guess-$scope.random; $scope.num++; $scope.guess=""; } $scope.again=function () { $scope.num=0; $scope.random=Math.ceil(Math.random()*10); console.log($scope.random) $scope.differ=null; $scope.guess=""; } }) myapp.controller("richengCtrl",function ($scope) { $scope.arr=[{ action:"爬山",done:false },{ action:"会友",done:false },{ action:"游泳",done:false },{ action:"唱歌",done:false },{ action:"喝酒",done:false },{ action:"约会",done:false },{ action:"休息",done:false }] $scope.addricheng=function () { $scope.arr.push({action:$scope.newaction,done:false}) $scope.newaction=""; } $scope.dones=[]; $scope.del1=function (index) { $scope.dones.push({action:$scope.arr[index].action,done:true}); $scope.arr.splice(index,1); } }) myapp.controller("homeCtrl",function ($scope,$http) { $http({ url:"package.json" }).then(function (data) { $scope.data=data.data; }) }) </script> </head> <body ng-app="myapp"> <ul> <li><a href="#home">首页</a></li> <li><a href="#one">第一页</a></li> <li><a href="#two">第二页</a></li> <li><a href="#three">第三页</a></li> <li><a href="#richeng">日程</a></li> </ul> <div ng-view=""></div> </body> </html>
路由大项目
最新推荐文章于 2022-04-27 23:51:05 发布