KnockoutJS Computed Observables
home
Run
screen_rotation
fullscreen
cloud_download
navigate_next
<!DOCTYPE html> <head> <title>KnockoutJS Example</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js" type="text/javascript"></script> </head> <body> <div> FirstName <input data-bind='value: firstname' /><br> LastName <input data-bind='value: lastname' /><br> Hello <span data-bind="text:fullname">. </div> <script> // data model content goes here var ViewModel = function() { this.firstname = ko.observable('Dave'); this.lastname = ko.observable('Smith'); this.fullname = ko.computed(function() { return this.firstname() + " " + this.lastname(); }, this); }; // Activate Knockout.JS ko.applyBindings(new ViewModel()); </script> </body> </html>
<!DOCTYPE html> <head> <title>KnockoutJS Example</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js" type="text/javascript"></script> </head> <body> <div> FirstName <input data-bind='value: firstname' /><br> LastName <input data-bind='value: lastname' /><br> Hello <span data-bind="text:fullname">. </div> <script> // data model content goes here var ViewModel = function() { this.firstname = ko.observable('Dave'); this.lastname = ko.observable('Smith'); this.fullname = ko.computed(function() { return this.firstname() + " " + this.lastname(); }, this); }; // Activate Knockout.JS ko.applyBindings(new ViewModel()); </script> </body> </html>
Copyrights@tutorialsplane.com