zoukankan      html  css  js  c++  java
  • angularjs实现时钟效果

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>动态时间例子</title>
    <script src="js/angular.min.js"></script>
    <script>
    var app=angular.module("timeDemo",[]);
    app.controller("timeCtrl",function($scope){
    //获取当前时间
    var now1=new Date();
    //让时间在页面显示
    $scope.Now=now1.getHours()+':'+now1.getMinutes()+':'+now1.getSeconds();

    //写一个方法获取当前时间
    $scope.SetTimer=function(){
    //angularJs的特性,需要手动把变化映射到html元素上面
    $scope.$apply(function(){
    var now=new Date();
    $scope.Now=now.getHours()+':'+now.getMinutes()+':'+now.getSeconds();
    });
    };
    //每隔1秒刷新一次时间
    $scope.SetTimerInterval=setInterval($scope.SetTimer,1000);
    });
    </script>
    </head>
    <body ng-app="timeDemo" ng-controller="timeCtrl">
    当前时间为:{{Now}}
    </body>
    </html>

  • 相关阅读:
    网站服务化
    网站服务化
    dubbo 服务化
    dubbo 服务化
    elk 搭建
    poj1840
    poj1840
    poj2299
    poj2299
    poj2388
  • 原文地址:https://www.cnblogs.com/luoguixin/p/6166334.html
Copyright © 2011-2022 走看看