angularjs實現猜大小功能,angularjs猜大小

來源:互聯網
上載者:User

angularjs實現猜大小功能,angularjs猜大小

本文執行個體為大家分享了angular.js數字猜大小的具體代碼,供大家參考,具體內容如下

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>猜大小</title> <script src="angular-1.5.5/angular.min.js"></script> <style>  *{   margin:0;   padding:0;   font-size: 30px;  }  input{   width: 500px;   height: 50px;  }  button{   width: 80px;   height: 50px;   border: 0;   text-align: center;   line-height: 50px;   color: white;   margin-left: 5px;  } </style> <script>  var m=angular.module("m",[]);  m.controller("my",function ($scope) {   $scope.check=function () {    $scope.differ=$scope.guess-$scope.random;    $scope.num++;   }   $scope.reset=function () {    $scope.guess=null;    $scope.differ=null;    $scope.num=0;    $scope.random=Math.ceil(Math.random()*10);   }   $scope.reset();  }) </script></head><body ng-app="m" ng-controller="my"><h1>請輸入一個1-10的整數</h1> <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">0</span>次</p></body></html>

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援幫客之家。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.