Skip to content

Instantly share code, notes, and snippets.

@kalinchernev
Created November 13, 2014 11:10
Show Gist options
  • Save kalinchernev/6b2eb43425951d7f6fec to your computer and use it in GitHub Desktop.
Save kalinchernev/6b2eb43425951d7f6fec to your computer and use it in GitHub Desktop.
Angular clock
<!doctype html>
<html ng-app="Time">
<head>
<title>Time</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
</head>
<body>
<div ng-controller="MyController">
<h1>{{ clock | date : 'medium' }}</h1>
</div>
<script type="text/javascript">
var app = angular.module('Time', []);
app.controller('MyController', function ($scope) {
$scope.clock = new Date();
var updateClock = function () {
$scope.clock = 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