Created
November 9, 2012 03:11
-
-
Save arisetyo/4043479 to your computer and use it in GitHub Desktop.
Introduction to Knockout.js
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> | |
<head> | |
<meta charset="utf-8"> | |
<title>hello-knockout-js</title> | |
</head> | |
<body> | |
<!-- syntax: data-bind="bindingName: bindingValue"--> | |
<p>Day: <input data-bind="value: dayOfWeek" /></p> | |
<p>To do: <input data-bind="value: activity" /></p> | |
<p>The day of the week is <span data-bind="text: dayOfWeek"></span>, so it's time for <span data-bind="text: activity"></span></p> | |
<script type='text/javascript' src='knockout-2.1.0.js'></script> | |
<script type='text/javascript'> | |
function viewModel() { | |
this.dayOfWeek = ko.observable('Monday'); | |
this.activity = ko.observable('getting stuck in traffic'); | |
}; | |
ko.applyBindings(new viewModel()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment