angularjs實現(xiàn)猜大小功能
更新時間:2017年10月23日 11:34:32 作者:飛鳥96
這篇文章主要為大家詳細介紹了angularjs實現(xiàn)猜大小功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了angular.js數(shù)字猜大小的具體代碼,供大家參考,具體內容如下
<!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的整數(shù)</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>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- angularjs實現(xiàn)猜數(shù)字大小功能
- 基于AngularJS實現(xiàn)頁面滾動到底自動加載數(shù)據(jù)的功能
- AngularJS+Node.js實現(xiàn)在線聊天室
- angularjs創(chuàng)建彈出框實現(xiàn)拖動效果
- 基于angularjs實現(xiàn)圖片放大鏡效果
- Angular2實現(xiàn)自定義雙向綁定屬性
- Angular.js 實現(xiàn)數(shù)字轉換漢字實例代碼
- angular-ui-sortable實現(xiàn)可拖拽排序列表
- AngularJS實現(xiàn)星星等級評分功能
- AngularJS實現(xiàn)的2048小游戲功能【附源碼下載】
相關文章
Angularjs 動態(tài)改變title標題(兼容ios)
這篇文章主要介紹了 Angularjs 動態(tài)改變title標題(兼容ios)的相關資料,需要的朋友可以參考下2016-12-12詳解Angularjs 自定義指令中的數(shù)據(jù)綁定
這篇文章主要介紹了Angularjs 自定義指令中的數(shù)據(jù)綁定,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-07-07