Καλώς ήρθατε στην σελίδα της Tech Place

How to create Data Bind in Javascript

28 Μάρ 2015

How to create Data Bind in Javascript

Posted by with - in Tutorials

  // This is a simple *viewmodel* – JavaScript that defines the data and behavior of your UI
function AppViewModel({
    this.firstName ko.observable(“Bert”);
    this.lastName ko.observable(“Bertington”);
    this.fullName ko.computed(function({
        return this.firstName(” ” this.lastName();    
    }this);
    this.capitalizeLastName function({
       var currentVal this.lastName();        // Read the current value
        this.lastName(currentVal.toUpperCase())// Write back a modified value
    };
}
    
// Activates knockout.js
ko.applyBindings(new AppViewModel());

Download File : bind

Comments are closed.