Skip to content

Instantly share code, notes, and snippets.

@foo9
Created February 2, 2014 08:31
Show Gist options
  • Save foo9/8764782 to your computer and use it in GitHub Desktop.
Save foo9/8764782 to your computer and use it in GitHub Desktop.
<!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