angularjs+生成随机数猜数字大小
2017-10-14 09:00
246 查看
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> *{ margin: 0; padding: 0; font-size: 30px; } input{ width: 500px; height: 50px; font-size: 30px; } button{ width: 80px; height: 50px; border: 0; text-align: center; line-height: 50px; background: darkblue; color: #fff; margin-left: 5px; } </style> <script src="angular/angular.js"></script> <script> var myapp=angular.module("myapp",[]); myapp.controller("myCtrl",function ($scope) { $scope.check=function () { console.log($scope.random); $scope.differ=$scope.guess-$scope.random; $scope.num++; }; $scope.reset=function () { $scope.differ=null; $scope.guess=null; $scope.num=0; $scope.random=Math.ceil(Math.random()*10); }; $scope.reset(); }) </script> </head> <body ng-app="myapp" ng-controller="myCtrl"> <h2>请输入一个1-10的整数</h2> <input type="text" ng-model="guess"><button ng-click="check()">检查</button><button ng-click="reset()">重置</button> <p ng-if="differ>0">猜大了</p> <p ng-if="differ<0">猜小了</p> <p ng-if="differ==0">猜对了</p> <p>一共猜了<span ng-bind="num"></span>次</p> </body> </html>
相关文章推荐
- angularjs+生成随机数猜数字大小
- AngularJS实现的生成随机数与猜数字大小功能示例
- js 生成随机数
- js生成随机数之random函数随机示例
- js生成随机数
- js随机数生成与排序
- JS生成不重复随机数
- js生成随机数
- js生成随机数方法收集
- js生成任意位数的随机数
- JS简单生成随机数(随机密码)的方法
- js 生成随机数
- c#与js随机数生成方法
- js中Math.random()生成指定范围数值的随机数
- js--引用类型单体内置对象--Math,随机数生成
- Js生成随机数的研究
- js生成指定范围内的随机数
- js生成随机数
- js随机点名 方式 和 js生成随机数 案例
- JS简单随机数生成方法