<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/angular.min.js" type="text/javascript" charset="UTF-8"></script>
<style>
#in1 {
background-color: blue;
}
#in2 {
background-color: green;
}
</style>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
我猜是:<input type="text" ng-model="number"/> <input id="in2" ng-click="verify()" type="button" value="验证" />
<input id="in1" type="button" value="再来一次" ng-click="play()" /><br />
<span ng-repeat="good in goods">{{good.shenme}}</span><br />
<span ng-repeat="good in goods">猜测次数{{good.cishu}}</span>
</body>
<script type="text/javascript">
var i=98;
var b=5;
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.verify=function(){
if(b<0){
return;
}
if($scope.number==i){
alert("aaa")
$scope.goods=[{shenme:"猜对了",cishu:0}];
}
if($scope.number>i){
alert("bbb")
$scope.goods=[{shenme:"你猜的数大了点",cishu:b--}];
}
if($scope.number<i){
alert("ccc")
$scope.goods=[{shenme:"你猜的数小了点",cishu:b--}];
}
}
$scope.play=function(){
b=5;
}
});
</script>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/angular.min.js" type="text/javascript" charset="UTF-8"></script>
<style>
#in1 {
background-color: blue;
}
#in2 {
background-color: green;
}
</style>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
我猜是:<input type="text" ng-model="number"/> <input id="in2" ng-click="verify()" type="button" value="验证" />
<input id="in1" type="button" value="再来一次" ng-click="play()" /><br />
<span ng-repeat="good in goods">{{good.shenme}}</span><br />
<span ng-repeat="good in goods">猜测次数{{good.cishu}}</span>
</body>
<script type="text/javascript">
var i=98;
var b=5;
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.verify=function(){
if(b<0){
return;
}
if($scope.number==i){
alert("aaa")
$scope.goods=[{shenme:"猜对了",cishu:0}];
}
if($scope.number>i){
alert("bbb")
$scope.goods=[{shenme:"你猜的数大了点",cishu:b--}];
}
if($scope.number<i){
alert("ccc")
$scope.goods=[{shenme:"你猜的数小了点",cishu:b--}];
}
}
$scope.play=function(){
b=5;
}
});
</script>
</html>