• angularjs 实现猜数字大小的功能


    1 <body ng-app="myapp" ng-controller="myCtrl">
    2     <h2>猜一猜,多大值?(1-1000)</h2>
    3     我猜是:<input type="text" ng-model="guess">
    4     <button ng-click="check()">验证</button><button ng-click="reset()">再玩一次</button><br>
    5     <span ng-if="fil>0">您猜的数大了</span>
    6     <span ng-if="fil<0">您猜的数小了</span>
    7     <span ng-if="fil==0">您猜对了</span>
    8     <p>猜的次数<span>{{n}}</span></p>
    9 </body>


    1
    <script src="angular.min.js"></script> 2 <script> 3 var myapp=angular.module("myapp",[]); 4 myapp.controller("myCtrl",function ($scope) { 5       //验证 6 $scope.check=function () { 7 console.log($scope.random);
                //根据差值判断显示、隐藏状态
    8 $scope.fil=$scope.guess-$scope.random; 9 $scope.n++; 10 11 };
              //重置方法
    12 $scope.reset=function () { 13 $scope.guess=null; 14 $scope.fil=null; 15 $scope.n = 0;
               //得到随机数
    16 $scope.random=Math.ceil(Math.random()*1000); 17 }; 18 $scope.reset(); 19 }) 20 21 22 23 </script>
  • 相关阅读:
    mini linux制作
    samba
    文件链接
    bz1234513
    shell中if判断语句
    文件系统层次结构
    ssh免密码登陆
    shell基础
    参考__Web前端大全
    参考__综合类网站大全
  • 原文地址:https://www.cnblogs.com/xjean/p/7497171.html
Copyright © 2020-2023  润新知