Created
February 2, 2014 08:31
-
-
Save foo9/8764782 to your computer and use it in GitHub Desktop.
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> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<p>姓:<input data-bind='value: firstName' /></p> | |
<p>名:<input data-bind='value: lastName' /></p> | |
<h2>わたしの名前は、<span data-bind="text: fullName"></span>です。</h2> | |
<script> | |
function ViewModel(first, last) { | |
this.firstName = ko.observable(first); | |
this.lastName = ko.observable(last); | |
this.fullName = ko.computed(function() { | |
return this.firstName() + " " + this.lastName(); | |
}, this); | |
}; | |
var viewModel = new ViewModel('太郎', '新宿'); | |
ko.applyBindings(viewModel); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment