Created
November 13, 2014 11:10
-
-
Save kalinchernev/6b2eb43425951d7f6fec to your computer and use it in GitHub Desktop.
Angular clock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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