Skip to content

Instantly share code, notes, and snippets.

@whisher
Created July 20, 2014 15:13
Show Gist options
  • Select an option

  • Save whisher/03c91973c376e9f4011e to your computer and use it in GitHub Desktop.

Select an option

Save whisher/03c91973c376e9f4011e to your computer and use it in GitHub Desktop.
<!doctype html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head>
<body>
<div ng-controller="MyController">
<h1>Hello {{ clock.now }}!</h1>
</div>
<script type="text/javascript">
angular.module('myApp', [])
.controller('MyController',function($scope){
$scope.clock = {
now :new Date()
};
var updateClock = function() {
$scope.clock.now = new Date();
};
setInterval(function() {
$scope.$apply(updateClock);
}, 1000);
updateClock();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment