本文主要为大家详细介绍了angularjs实现猜大小功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助大家。

本文实例为大家分享了angular.js数字猜大小的具体代码,供大家参考,具体内容如下

猜大小

*{

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;

}

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();

})

请输入一个1-10的整数

检查重置

猜大了

猜小了

猜对了

你一共才了0次

相关推荐:

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐