<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Name Widget.</title> <script src="scripts/jquery-2.1.1.min.js"></script> <script src="scripts/knockout-3.2.0.js"></script> <script> $(document).ready(function() { ko.components.register('name-widget', { viewModel: function (params) { this.name = params.value(); //Getting the bind property. params.value("Sumanth"); //Changing the parent property. (It changing the parent but not child property). }, template: "<p>Your name is:<span data-bind='text: name'></span></p>" }); function nameViewModel() { this.myName = ko.observable("Sudheer"); } ko.applyBindings(new nameViewModel()); }) </script> </head> <body> Type in your name: <input type="text" data-bind="value: myName" /> <span data-bind="text: myName"></span> <!--Widget--> <name-widget params="value: myName"></name-widget> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)