Created
February 19, 2015 18:05
-
-
Save idmontie/e0c0a048e672964d5d12 to your computer and use it in GitHub Desktop.
KnockoutJS Two Way Data Binding Example
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
<input data-bind="value: firstName" placeholder="first name"/> | |
<input data-bind="value: lastName" placeholder="last name"/> | |
<p data-bind="text: fullName()"></p> | |
<script> | |
var viewModel = function () { | |
var self = this; | |
self.firstName = ko.observable( 'Ivan' ); | |
self.lastName = ko.observable( 'M' ); | |
self.fullName = ko.computed( function () { | |
return self.firstName() + ' ' + self.lastName(); | |
} ); | |
}; | |
ko.applyBindings( viewModel ); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment