Created
November 10, 2010 22:33
-
-
Save mhevery/671665 to your computer and use it in GitHub Desktop.
This file contains 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 xmlns:ng="http://angularjs.org"> | |
<script type="text/javascript" ng:autobind | |
src="http://code.angularjs.org/angular-0.9.2.min.js"></script> | |
<body> | |
<script> | |
angular.widget('my:time', function(compileElement /* i am a subset of jquery http://angularjs.org/Angular.element() */){ | |
compileElement.css('display', 'block'); | |
return function(linkElement /* i am a subset of jquery http://angularjs.org/Angular.element() */){ | |
var div = angular.element('<div>Current time is: </div>'); | |
var span = angular.element('<span></span>'); | |
span.css('font-family', 'monospace'); | |
linkElement.append(div); | |
div.append(span); | |
function update(){ | |
span.text(new Date()); | |
setTimeout(update, 1000); | |
} | |
update(); | |
}; | |
}); | |
</script> | |
Look at me you can include me anywhere in text: <my:time></my:time> | |
<div style="float: right;"> | |
Or style me any way you want: <my:time style="border: 1px solid green;"></my:time> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment