• angularjs事例


    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Guess The Number !</title>
    <link href="bootstrap.min.css" rel="stylesheet">
    </head>

    <body ng-app="app">
    <div class="container" ng-controller="GuessTheNumberController">
    <h2>猜数字 !</h2>
    <p class="well lead">请猜出电脑生成的随机数,它的范围在1到1000之间.</p>
    <label>请您出手: </label><input type="number" ng-model="guess"/>
    <button ng-click="verifyGuess()" class="btn btn-primary btn-sm">确定</button>
    <button ng-click="initializeGame()" class="btn btn-warning btn-sm">重来</button>
    <p>
    <p ng-show="deviation<0" class="alert alert-warning">爷,您出价过高了!</p>
    <p ng-show="deviation>0" class="alert alert-warning">爷,少了点,再加点,再加点.</p>
    <p ng-show="deviation===0" class="alert alert-success">爷,还真让您说准了!.</p>
    </p>
    <p class="text-info">您猜过的次数是 : <span class="badge">{{numOfTries}}</span><p>
    </div>
    <script src="angular.js"></script>
    <script type="text/javascript">
    angular.module('app',[])
    .controller('GuessTheNumberController', GuessTheNumberController);

    function GuessTheNumberController($scope) {
    $scope.verifyGuess = function () {
    $scope.deviation = $scope.originalVal - $scope.userGuess;
    $scope.numOfTries = $scope.numOfTries + 1;
    }
    $scope.initializeGame=function() {
    $scope.numOfTries = 0;
    $scope.originalVal = Math.floor((Math.random() * 1000) + 1);
    $scope.userGuess = null;
    $scope.deviation = null;
    }
    alert("1");
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    nginx upstream permission denied错误解决
    基于Mariadb 10.6.4在CentOS 7环境下配置Galera Cluster集群
    K8s 开始
    RTSP H264/HEVC 流 Wasm 播放
    Netty编码示例(RPC & WbeSocket & Tomcat)
    Netty异步任务调度与异步线程池
    Netty编解码器&TCP粘包拆包
    Netty核心模块组件
    Neety编码示例(群聊系统&⼼跳检测&WebSocket⻓连接)
    Netty高性能架构设计
  • 原文地址:https://www.cnblogs.com/LGDD/p/7169728.html
Copyright © 2020-2023  润新知