Learning Knockout Js

Knockout JS


Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model.

Knockout js is client side only it simplifies the html (or view) and java script (or model) to make a more manageable and dynamic web interface. 

My first project with knockout js


// HTML
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<h2>Hello, <span data-bind="text: fullName"> </span>!</h2>

// JavaScript Code
var ViewModel = function(first, last) {
    this.firstName = ko.observable(first);
    this.lastName = ko.observable(last);
 
    this.fullName = ko.pureComputed(function() {
        
        return this.firstName() + " " + this.lastName();
    }, this);
};
 
ko.applyBindings(new ViewModel("Planet", "Earth"));

Popular posts from this blog

Visual Studio Profiler: Performance Optimisation