案例:AngularJS案例     状态:可编辑再运行    进入横版
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<script src="/js/angular.js1.4.6/angular.min.js"></script>
6
</head>
7
<body>
8
9
<div ng-app="myApp" ng-controller="myCtrl"> 
10
11
<p>现在时间是:</p>
12
13
<h1>{{theTime}}</h1>
14
15
</div>
16
17
<p>$interval 访问在指定的周期(以毫秒计)来调用函数或计算表达式。</p>
18
19
<script>
20
var app = angular.module('myApp', []);
21
app.controller('myCtrl', function($scope, $interval) {
22
  $scope.theTime = new Date().toLocaleTimeString();
23
  $interval(function () {
24
      $scope.theTime = new Date().toLocaleTimeString();

 运行结果 
 北美留学生论坛