KnockoutJS is widely used for Single Page Applications - A website created with the ability to retrieve all necessary data dynamically with a single page load reducing server round trips.
<!DOCTYPE html> <head> <title>KnockoutJS Observable Example</title> <script src = "https://ajax.aspnetcdn.com/ajax/knockout/knockout-3.1.0.js" type = "text/javascript"></script> </head> <body> <!-- This is called "view" of HTML markup that defines the appearance of UI --> <p>Enter your name: <input data-bind = "value: yourName" /></p> <p>Hi <strong data-bind = "text: yourName"></strong> Good Morning!!!</p> <script> //This is called "viewmodel". This javascript section defines the data and behavior of UI function AppViewModel() { this.yourName = ko.observable(""); } // Activates knockout.js ko.applyBindings(new AppViewModel()); </script> </body> </html>
output
ไม่มีความคิดเห็น:
แสดงความคิดเห็น